dateTimePicker C# visual studio 2003

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vinsent
    New Member
    • Nov 2009
    • 2

    dateTimePicker C# visual studio 2003

    When I put the DateTimePicker on the windows form and conect them with database (sql data adapter) and add new record I get current date in the field.
    that is OK , but when I start update metod of sql dataad apter the date on the Date Time Picker is not reflect in the database.

    Does enybody know Why?
  • lotus18
    Contributor
    • Nov 2007
    • 865

    #2
    Would you like to post your sample codes here so we can analyze waht your problem is? Just double check your update query

    Rey Sean

    Comment

    • vinsent
      New Member
      • Nov 2009
      • 2

      #3
      Hallo Ray, thank you for help. The code follow

      Code:
      using System;
      using System.Drawing;
      using System.Collections;
      using System.ComponentModel;
      using System.Windows.Forms;
      using System.Data;
      
      
      namespace projekat
      {
      	/// <summary>
      	/// Summary description for Form1.
      	/// </summary>
      	public class Form1 : System.Windows.Forms.Form
      	{
      		private System.Windows.Forms.ToolBar toolBar1;
      		private System.Windows.Forms.ImageList imageList1;
      		private System.Windows.Forms.ToolBarButton tbb1;
      		private System.Windows.Forms.ToolBarButton tbb2;
      		private System.Windows.Forms.ToolBarButton tbb3;
      		private System.Windows.Forms.ToolBarButton tbb4;
      		private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
      		private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
      		private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
      		private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
      		private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
      		private System.Data.SqlClient.SqlConnection sqlConnection1;
      		private projekat.DataSet1 dataSet11;
      		private System.Windows.Forms.TextBox naziv;
      		private System.Windows.Forms.TextBox pdv;
      		public System.Windows.Forms.DateTimePicker valuta;
      		
      		private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter2;
      		private System.Data.SqlClient.SqlCommand sqlSelectCommand2;
      		private System.Data.SqlClient.SqlCommand sqlInsertCommand2;
      		private System.Data.SqlClient.SqlCommand sqlUpdateCommand2;
      		private System.Data.SqlClient.SqlCommand sqlDeleteCommand2;
      		private projekat.DataSet2 dataSet21;
      		private System.Windows.Forms.Button button1;
      		private System.Windows.Forms.Button button2;
      		private System.Windows.Forms.ComboBox comboBox1;
      		public System.Windows.Forms.ComboBox comboBox2;
      		private System.Windows.Forms.Label label1;
      		private System.Windows.Forms.Label label2;
      		private System.Windows.Forms.Label label3;
      		private System.Windows.Forms.Label label4;
      		private System.Windows.Forms.Label label5;
      		private System.Windows.Forms.Label label6;
      		private System.ComponentModel.IContainer components;
      	public DateTime dt;
      
      		public Form1()
      		{
      		
      			//
      			// Required for Windows Form Designer support
      			//
      			InitializeComponent();
      	
      			//
      			// TODO: Add any constructor code after InitializeComponent call
      			//
      		}
      
      		/// <summary>
      		/// Clean up any resources being used.
      		/// </summary>
      		protected override void Dispose( bool disposing )
      		{
      			if( disposing )
      			{
      				if (components != null) 
      				{
      					components.Dispose();
      				}
      			}
      			base.Dispose( disposing );
      		}
      
      		#region Windows Form Designer generated code
      		/// <summary>
      		/// Required method for Designer support - do not modify
      		/// the contents of this method with the code editor.
      		/// </summary>
      		private void InitializeComponent()
      		{
      			this.components = new System.ComponentModel.Container();
      			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
      			this.toolBar1 = new System.Windows.Forms.ToolBar();
      			this.tbb1 = new System.Windows.Forms.ToolBarButton();
      			this.tbb2 = new System.Windows.Forms.ToolBarButton();
      			this.tbb3 = new System.Windows.Forms.ToolBarButton();
      			this.tbb4 = new System.Windows.Forms.ToolBarButton();
      			this.imageList1 = new System.Windows.Forms.ImageList(this.components);
      			this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
      			this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
      			this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
      			this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
      			this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
      			this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
      			this.dataSet11 = new projekat.DataSet1();
      			this.naziv = new System.Windows.Forms.TextBox();
      			this.pdv = new System.Windows.Forms.TextBox();
      			this.dataSet21 = new projekat.DataSet2();
      			this.valuta = new System.Windows.Forms.DateTimePicker();
      			this.sqlDataAdapter2 = new System.Data.SqlClient.SqlDataAdapter();
      			this.sqlDeleteCommand2 = new System.Data.SqlClient.SqlCommand();
      			this.sqlInsertCommand2 = new System.Data.SqlClient.SqlCommand();
      			this.sqlSelectCommand2 = new System.Data.SqlClient.SqlCommand();
      			this.sqlUpdateCommand2 = new System.Data.SqlClient.SqlCommand();
      			this.button1 = new System.Windows.Forms.Button();
      			this.button2 = new System.Windows.Forms.Button();
      			this.comboBox1 = new System.Windows.Forms.ComboBox();
      			this.comboBox2 = new System.Windows.Forms.ComboBox();
      			this.label1 = new System.Windows.Forms.Label();
      			this.label2 = new System.Windows.Forms.Label();
      			this.label3 = new System.Windows.Forms.Label();
      			this.label4 = new System.Windows.Forms.Label();
      			this.label5 = new System.Windows.Forms.Label();
      			this.label6 = new System.Windows.Forms.Label();
      			((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
      			((System.ComponentModel.ISupportInitialize)(this.dataSet21)).BeginInit();
      			this.SuspendLayout();
      			// 
      			// toolBar1
      			// 
      			this.toolBar1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
      			this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
      																						this.tbb1,
      																						this.tbb2,
      																						this.tbb3,
      																						this.tbb4});
      			this.toolBar1.ButtonSize = new System.Drawing.Size(32, 31);
      			this.toolBar1.DropDownArrows = true;
      			this.toolBar1.ImageList = this.imageList1;
      			this.toolBar1.Location = new System.Drawing.Point(0, 0);
      			this.toolBar1.Name = "toolBar1";
      			this.toolBar1.ShowToolTips = true;
      			this.toolBar1.Size = new System.Drawing.Size(632, 38);
      			this.toolBar1.TabIndex = 0;
      			this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
      			// 
      			// tbb1
      			// 
      			this.tbb1.ImageIndex = 0;
      			this.tbb1.ToolTipText = "New";
      			// 
      			// tbb2
      			// 
      			this.tbb2.ImageIndex = 1;
      			this.tbb2.ToolTipText = "Save";
      			// 
      			// tbb3
      			// 
      			this.tbb3.ImageIndex = 2;
      			this.tbb3.ToolTipText = "Delete";
      			// 
      			// tbb4
      			// 
      			this.tbb4.ImageIndex = 3;
      			this.tbb4.ToolTipText = "Kraj";
      			// 
      			// imageList1
      			// 
      			this.imageList1.ImageSize = new System.Drawing.Size(20, 20);
      			this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
      			this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
      			// 
      			// sqlDataAdapter1
      			// 
      			this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
      			this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
      			this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
      			this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
      																									  new System.Data.Common.DataTableMapping("Table", "faktura", new System.Data.Common.DataColumnMapping[] {
      																																																				 new System.Data.Common.DataColumnMapping("idfak", "idfak"),
      																																																				 new System.Data.Common.DataColumnMapping("iddob", "iddob"),
      																																																				 new System.Data.Common.DataColumnMapping("naziv", "naziv"),
      																																																				 new System.Data.Common.DataColumnMapping("valuta", "valuta"),
      																																																				 new System.Data.Common.DataColumnMapping("pdv", "pdv")})});
      			this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
      			// 
      			// sqlDeleteCommand1
      			// 
      			this.sqlDeleteCommand1.CommandText = @"DELETE FROM faktura WHERE (idfak = @Original_idfak) AND (iddob = @Original_iddob OR @Original_iddob IS NULL AND iddob IS NULL) AND (pdv = @Original_pdv OR @Original_pdv IS NULL AND pdv IS NULL) AND (valuta = @Original_valuta OR @Original_valuta IS NULL AND valuta IS NULL)";
      			this.sqlDeleteCommand1.Connection = this.sqlConnection1;
      			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_idfak", System.Data.SqlDbType.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "idfak", System.Data.DataRowVersion.Original, null));
      			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_iddob", System.Data.SqlDbType.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "iddob", System.Data.DataRowVersion.Original, null));
      			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_pdv", System.Data.SqlDbType.Decimal, 9, System.Data.ParameterDirection.Input, false, ((System.Byte)(18)), ((System.Byte)(0)), "pdv", System.Data.DataRowVersion.Original, null));
      			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_valuta", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "valuta", System.Data.DataRowVersion.Original, null));
      			// 
      			// sqlConnection1
      			// 
      			this.sqlConnection1.ConnectionString = "workstation id=DEJAN;packet size=4096;integrated security=SSPI;data source=DEJAN;" +
      				"persist security info=False;initial catalog=probna";
      			// 
      			// sqlInsertCommand1
      			// 
      			this.sqlInsertCommand1.CommandText = "INSERT INTO faktura(iddob, naziv, valuta, pdv) VALUES (@iddob, @naziv, @valuta, @" +
      				"pdv); SELECT idfak, iddob, naziv, valuta, pdv FROM faktura WHERE (idfak = @@IDEN" +
      				"TITY)";
      			this.sqlInsertCommand1.Connection = this.sqlConnection1;
      			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@iddob", System.Data.SqlDbType.BigInt, 8, "iddob"));
      			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@naziv", System.Data.SqlDbType.VarChar, 2147483647, "naziv"));
      			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@valuta", System.Data.SqlDbType.DateTime, 8, "valuta"));
      			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@pdv", System.Data.SqlDbType.Decimal, 9, System.Data.ParameterDirection.Input, false, ((System.Byte)(18)), ((System.Byte)(0)), "pdv", System.Data.DataRowVersion.Current, null));
      			// 
      			// sqlSelectCommand1
      			// 
      			this.sqlSelectCommand1.CommandText = "SELECT idfak, iddob, naziv, valuta, pdv FROM faktura";
      			this.sqlSelectCommand1.Connection = this.sqlConnection1;
      			// 
      			// sqlUpdateCommand1
      			// 
      			this.sqlUpdateCommand1.CommandText = @"UPDATE faktura SET iddob = @iddob, naziv = @naziv, valuta = @valuta, pdv = @pdv WHERE (idfak = @Original_idfak) AND (iddob = @Original_iddob OR @Original_iddob IS NULL AND iddob IS NULL) AND (pdv = @Original_pdv OR @Original_pdv IS NULL AND pdv IS NULL) AND (valuta = @Original_valuta OR @Original_valuta IS NULL AND valuta IS NULL); SELECT idfak, iddob, naziv, valuta, pdv FROM faktura WHERE (idfak = @idfak)";
      			this.sqlUpdateCommand1.Connection = this.sqlConnection1;
      			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@iddob", System.Data.SqlDbType.BigInt, 8, "iddob"));
      			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@naziv", System.Data.SqlDbType.VarChar, 2147483647, "naziv"));
      			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@valuta", System.Data.SqlDbType.DateTime, 8, "valuta"));
      			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@pdv", System.Data.SqlDbType.Decimal, 9, System.Data.ParameterDirection.Input, false, ((System.Byte)(18)), ((System.Byte)(0)), "pdv", System.Data.DataRowVersion.Current, null));
      			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_idfak", System.Data.SqlDbType.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "idfak", System.Data.DataRowVersion.Original, null));
      			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_iddob", System.Data.SqlDbType.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "iddob", System.Data.DataRowVersion.Original, null));
      			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_pdv", System.Data.SqlDbType.Decimal, 9, System.Data.ParameterDirection.Input, false, ((System.Byte)(18)), ((System.Byte)(0)), "pdv", System.Data.DataRowVersion.Original, null));
      			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_valuta", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "valuta", System.Data.DataRowVersion.Original, null));
      			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@idfak", System.Data.SqlDbType.BigInt, 8, "idfak"));
      			// 
      			// dataSet11
      			// 
      			this.dataSet11.DataSetName = "DataSet1";
      			this.dataSet11.Locale = new System.Globalization.CultureInfo("en-GB");
      			// 
      			// naziv
      			// 
      			this.naziv.Anchor = System.Windows.Forms.AnchorStyles.Top;
      			this.naziv.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "faktura.naziv"));
      			this.naziv.Location = new System.Drawing.Point(168, 128);
      			this.naziv.Name = "naziv";
      			this.naziv.Size = new System.Drawing.Size(360, 20);
      			this.naziv.TabIndex = 4;
      			this.naziv.Text = "";
      			// 
      			// pdv
      			// 
      			this.pdv.Anchor = System.Windows.Forms.AnchorStyles.Top;
      			this.pdv.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "faktura.pdv"));
      			this.pdv.Location = new System.Drawing.Point(376, 168);
      			this.pdv.Name = "pdv";
      			this.pdv.Size = new System.Drawing.Size(48, 20);
      			this.pdv.TabIndex = 5;
      			this.pdv.Text = "";
      			this.pdv.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
      			// 
      			// dataSet21
      			// 
      			this.dataSet21.DataSetName = "DataSet2";
      			this.dataSet21.Locale = new System.Globalization.CultureInfo("en-GB");
      			// 
      			// valuta
      			// 
      			this.valuta.AccessibleRole = System.Windows.Forms.AccessibleRole.Window;
      			this.valuta.Anchor = System.Windows.Forms.AnchorStyles.Top;
      			this.valuta.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "faktura.valuta"));
      			this.valuta.Format = System.Windows.Forms.DateTimePickerFormat.Short;
      			this.valuta.ImeMode = System.Windows.Forms.ImeMode.HangulFull;
      			this.valuta.Location = new System.Drawing.Point(300, 80);
      			this.valuta.Name = "valuta";
      			this.valuta.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
      			this.valuta.Size = new System.Drawing.Size(92, 20);
      			this.valuta.TabIndex = 2;
      			this.valuta.Value = new System.DateTime(2009, 11, 26, 0, 0, 0, 0);
      			// 
      			// sqlDataAdapter2
      			// 
      			this.sqlDataAdapter2.DeleteCommand = this.sqlDeleteCommand2;
      			this.sqlDataAdapter2.InsertCommand = this.sqlInsertCommand2;
      			this.sqlDataAdapter2.SelectCommand = this.sqlSelectCommand2;
      			this.sqlDataAdapter2.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
      																									  new System.Data.Common.DataTableMapping("Table", "dobavljac", new System.Data.Common.DataColumnMapping[] {
      																																																				   new System.Data.Common.DataColumnMapping("iddobavljac", "iddobavljac"),
      																																																				   new System.Data.Common.DataColumnMapping("naziv", "naziv")})});
      			this.sqlDataAdapter2.UpdateCommand = this.sqlUpdateCommand2;
      			// 
      			// sqlDeleteCommand2
      			// 
      			this.sqlDeleteCommand2.CommandText = "DELETE FROM dobavljac WHERE (iddobavljac = @Original_iddobavljac) AND (naziv = @O" +
      				"riginal_naziv OR @Original_naziv IS NULL AND naziv IS NULL)";
      			this.sqlDeleteCommand2.Connection = this.sqlConnection1;
      			this.sqlDeleteCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_iddobavljac", System.Data.SqlDbType.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "iddobavljac", System.Data.DataRowVersion.Original, null));
      			this.sqlDeleteCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_naziv", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "naziv", System.Data.DataRowVersion.Original, null));
      			// 
      			// sqlInsertCommand2
      			// 
      			this.sqlInsertCommand2.CommandText = "INSERT INTO dobavljac(naziv) VALUES (@naziv); SELECT iddobavljac, naziv FROM doba" +
      				"vljac WHERE (iddobavljac = @@IDENTITY)";
      			this.sqlInsertCommand2.Connection = this.sqlConnection1;
      			this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@naziv", System.Data.SqlDbType.VarChar, 50, "naziv"));
      			// 
      			// sqlSelectCommand2
      			// 
      			this.sqlSelectCommand2.CommandText = "SELECT iddobavljac, naziv FROM dobavljac";
      			this.sqlSelectCommand2.Connection = this.sqlConnection1;
      			// 
      			// sqlUpdateCommand2
      			// 
      			this.sqlUpdateCommand2.CommandText = "UPDATE dobavljac SET naziv = @naziv WHERE (iddobavljac = @Original_iddobavljac) A" +
      				"ND (naziv = @Original_naziv OR @Original_naziv IS NULL AND naziv IS NULL); SELEC" +
      				"T iddobavljac, naziv FROM dobavljac WHERE (iddobavljac = @iddobavljac)";
      			this.sqlUpdateCommand2.Connection = this.sqlConnection1;
      			this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@naziv", System.Data.SqlDbType.VarChar, 50, "naziv"));
      			this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_iddobavljac", System.Data.SqlDbType.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "iddobavljac", System.Data.DataRowVersion.Original, null));
      			this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_naziv", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "naziv", System.Data.DataRowVersion.Original, null));
      			this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@iddobavljac", System.Data.SqlDbType.BigInt, 8, "iddobavljac"));
      			// 
      			// button1
      			// 
      			this.button1.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
      			this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image")));
      			this.button1.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
      			this.button1.Location = new System.Drawing.Point(192, 232);
      			this.button1.Name = "button1";
      			this.button1.Size = new System.Drawing.Size(64, 23);
      			this.button1.TabIndex = 2;
      			this.button1.TabStop = false;
      			this.button1.Text = "Next";
      			this.button1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
      			this.button1.Click += new System.EventHandler(this.button1_Click);
      			// 
      			// button2
      			// 
      			this.button2.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
      			this.button2.Image = ((System.Drawing.Image)(resources.GetObject("button2.Image")));
      			this.button2.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
      			this.button2.Location = new System.Drawing.Point(328, 232);
      			this.button2.Name = "button2";
      			this.button2.Size = new System.Drawing.Size(64, 23);
      			this.button2.TabIndex = 7;
      			this.button2.TabStop = false;
      			this.button2.Text = "Prev";
      			this.button2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      			this.button2.Click += new System.EventHandler(this.button2_Click);
      			// 
      			// comboBox1
      			// 
      			this.comboBox1.Anchor = System.Windows.Forms.AnchorStyles.Top;
      			this.comboBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "faktura.idfak"));
      			this.comboBox1.DataSource = this.dataSet11;
      			this.comboBox1.DisplayMember = "faktura.idfak";
      			this.comboBox1.Location = new System.Drawing.Point(92, 80);
      			this.comboBox1.Name = "comboBox1";
      			this.comboBox1.Size = new System.Drawing.Size(84, 21);
      			this.comboBox1.TabIndex = 1;
      			this.comboBox1.ValueMember = "idfak";
      			// 
      			// comboBox2
      			// 
      			this.comboBox2.Anchor = System.Windows.Forms.AnchorStyles.Top;
      			this.comboBox2.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet21, "dobavljac.naziv"));
      			this.comboBox2.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.dataSet11, "faktura.iddob"));
      			this.comboBox2.DataSource = this.dataSet21.dobavljac;
      			this.comboBox2.DisplayMember = "naziv";
      			this.comboBox2.Location = new System.Drawing.Point(492, 80);
      			this.comboBox2.Name = "comboBox2";
      			this.comboBox2.Size = new System.Drawing.Size(121, 21);
      			this.comboBox2.TabIndex = 3;
      			this.comboBox2.ValueMember = "iddobavljac";
      			this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.promena);
      			// 
      			// label1
      			// 
      			this.label1.BackColor = System.Drawing.SystemColors.Info;
      			this.label1.Dock = System.Windows.Forms.DockStyle.Top;
      			this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
      			this.label1.Location = new System.Drawing.Point(0, 38);
      			this.label1.Name = "label1";
      			this.label1.Size = new System.Drawing.Size(632, 23);
      			this.label1.TabIndex = 10;
      			this.label1.Text = "Faktura";
      			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
      			// 
      			// label2
      			// 
      			this.label2.Anchor = System.Windows.Forms.AnchorStyles.Top;
      			this.label2.Location = new System.Drawing.Point(20, 80);
      			this.label2.Name = "label2";
      			this.label2.Size = new System.Drawing.Size(56, 20);
      			this.label2.TabIndex = 11;
      			this.label2.Text = "ID";
      			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      			// 
      			// label3
      			// 
      			this.label3.Anchor = System.Windows.Forms.AnchorStyles.Top;
      			this.label3.Location = new System.Drawing.Point(244, 80);
      			this.label3.Name = "label3";
      			this.label3.Size = new System.Drawing.Size(40, 20);
      			this.label3.TabIndex = 12;
      			this.label3.Text = "Valuta";
      			this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      			// 
      			// label4
      			// 
      			this.label4.Anchor = System.Windows.Forms.AnchorStyles.Top;
      			this.label4.Location = new System.Drawing.Point(388, 80);
      			this.label4.Name = "label4";
      			this.label4.Size = new System.Drawing.Size(100, 20);
      			this.label4.TabIndex = 13;
      			this.label4.Text = "Costumers";
      			this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      			// 
      			// label5
      			// 
      			this.label5.Anchor = System.Windows.Forms.AnchorStyles.Top;
      			this.label5.Location = new System.Drawing.Point(112, 128);
      			this.label5.Name = "label5";
      			this.label5.Size = new System.Drawing.Size(40, 23);
      			this.label5.TabIndex = 14;
      			this.label5.Text = "Detail";
      			this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      			// 
      			// label6
      			// 
      			this.label6.Anchor = System.Windows.Forms.AnchorStyles.Top;
      			this.label6.Location = new System.Drawing.Point(312, 168);
      			this.label6.Name = "label6";
      			this.label6.Size = new System.Drawing.Size(48, 20);
      			this.label6.TabIndex = 15;
      			this.label6.Text = "Pdv";
      			this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      			// 
      			// Form1
      			// 
      			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      			this.ClientSize = new System.Drawing.Size(632, 273);
      			this.Controls.Add(this.label6);
      			this.Controls.Add(this.label5);
      			this.Controls.Add(this.label4);
      			this.Controls.Add(this.label3);
      			this.Controls.Add(this.label2);
      			this.Controls.Add(this.label1);
      			this.Controls.Add(this.comboBox2);
      			this.Controls.Add(this.comboBox1);
      			this.Controls.Add(this.button2);
      			this.Controls.Add(this.button1);
      			this.Controls.Add(this.valuta);
      			this.Controls.Add(this.pdv);
      			this.Controls.Add(this.naziv);
      			this.Controls.Add(this.toolBar1);
      			this.Name = "Form1";
      			this.Text = "Form1";
      			this.Load += new System.EventHandler(this.Form1_Load);
      			((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
      			((System.ComponentModel.ISupportInitialize)(this.dataSet21)).EndInit();
      			this.ResumeLayout(false);
      
      		}
      		#endregion
      
      		/// <summary>
      		/// The main entry point for the application.
      		/// </summary>
      		[STAThread]
      		static void Main() 
      		{
      			Application.Run(new Form1());
      			
      		}
      
      		private void Form1_Load(object sender, System.EventArgs e)
      		{
      			this.sqlDataAdapter1.Fill(this.dataSet11,0,0,"faktura");
      			this.sqlDataAdapter2.Fill(this.dataSet21,0,0,"dobavljac");
      			
      //			
      
      
      		}
      		
      
      		private void button1_Click(object sender, System.EventArgs e)
      		{
      			this.BindingContext[this.dataSet11,"faktura"].Position++;
      		
      //				
      			
      			}
      
      
      		private void button2_Click(object sender, System.EventArgs e)
      		{
      			this.BindingContext[this.dataSet11,"faktura"].Position--;
      		
      		}
      
      		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
      		{
      			if (e.Button.ImageIndex==0)
      			{
      				
      				this.BindingContext[this.dataSet11,"faktura"].AddNew();
      
      				
      				
      			}
      			if (e.Button.ImageIndex==1)
      			{
      			   
      				this.BindingContext[this.dataSet11,"faktura"].EndCurrentEdit();
      			
      				this.sqlDataAdapter1.Update(this.dataSet11,"faktura");
      				
      			}
      			if(e.Button.ImageIndex==2)
      			{
      				int i=this.BindingContext[this.dataSet11,"faktura"].Position;
      				this.BindingContext[this.dataSet11,"faktura"].RemoveAt(i);
      			}
      				
      		}
      
      		private void promena(object sender, System.EventArgs e)
      		{
      			ComboBox cv=(ComboBox)sender;
      			if (cv.SelectedIndex==0)
      				cv.SelectedIndex=-1;
      
      		}
      
      		
      		
      	}
      }
      Last edited by tlhintoq; Nov 30 '09, 02:51 AM. Reason: [CODE] ...your code here... [/CODE] tags added

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.

        Comment

        Working...