473,471 Members | 1,898 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

dateTimePicker C# visual studio 2003

2 New Member
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?
Nov 28 '09 #1
3 2303
lotus18
866 Contributor
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
Nov 29 '09 #2
vinsent
2 New Member
Hallo Ray, thank you for help. The code follow

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7.  
  8.  
  9. namespace projekat
  10. {
  11.     /// <summary>
  12.     /// Summary description for Form1.
  13.     /// </summary>
  14.     public class Form1 : System.Windows.Forms.Form
  15.     {
  16.         private System.Windows.Forms.ToolBar toolBar1;
  17.         private System.Windows.Forms.ImageList imageList1;
  18.         private System.Windows.Forms.ToolBarButton tbb1;
  19.         private System.Windows.Forms.ToolBarButton tbb2;
  20.         private System.Windows.Forms.ToolBarButton tbb3;
  21.         private System.Windows.Forms.ToolBarButton tbb4;
  22.         private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
  23.         private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
  24.         private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
  25.         private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
  26.         private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
  27.         private System.Data.SqlClient.SqlConnection sqlConnection1;
  28.         private projekat.DataSet1 dataSet11;
  29.         private System.Windows.Forms.TextBox naziv;
  30.         private System.Windows.Forms.TextBox pdv;
  31.         public System.Windows.Forms.DateTimePicker valuta;
  32.  
  33.         private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter2;
  34.         private System.Data.SqlClient.SqlCommand sqlSelectCommand2;
  35.         private System.Data.SqlClient.SqlCommand sqlInsertCommand2;
  36.         private System.Data.SqlClient.SqlCommand sqlUpdateCommand2;
  37.         private System.Data.SqlClient.SqlCommand sqlDeleteCommand2;
  38.         private projekat.DataSet2 dataSet21;
  39.         private System.Windows.Forms.Button button1;
  40.         private System.Windows.Forms.Button button2;
  41.         private System.Windows.Forms.ComboBox comboBox1;
  42.         public System.Windows.Forms.ComboBox comboBox2;
  43.         private System.Windows.Forms.Label label1;
  44.         private System.Windows.Forms.Label label2;
  45.         private System.Windows.Forms.Label label3;
  46.         private System.Windows.Forms.Label label4;
  47.         private System.Windows.Forms.Label label5;
  48.         private System.Windows.Forms.Label label6;
  49.         private System.ComponentModel.IContainer components;
  50.     public DateTime dt;
  51.  
  52.         public Form1()
  53.         {
  54.  
  55.             //
  56.             // Required for Windows Form Designer support
  57.             //
  58.             InitializeComponent();
  59.  
  60.             //
  61.             // TODO: Add any constructor code after InitializeComponent call
  62.             //
  63.         }
  64.  
  65.         /// <summary>
  66.         /// Clean up any resources being used.
  67.         /// </summary>
  68.         protected override void Dispose( bool disposing )
  69.         {
  70.             if( disposing )
  71.             {
  72.                 if (components != null) 
  73.                 {
  74.                     components.Dispose();
  75.                 }
  76.             }
  77.             base.Dispose( disposing );
  78.         }
  79.  
  80.         #region Windows Form Designer generated code
  81.         /// <summary>
  82.         /// Required method for Designer support - do not modify
  83.         /// the contents of this method with the code editor.
  84.         /// </summary>
  85.         private void InitializeComponent()
  86.         {
  87.             this.components = new System.ComponentModel.Container();
  88.             System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
  89.             this.toolBar1 = new System.Windows.Forms.ToolBar();
  90.             this.tbb1 = new System.Windows.Forms.ToolBarButton();
  91.             this.tbb2 = new System.Windows.Forms.ToolBarButton();
  92.             this.tbb3 = new System.Windows.Forms.ToolBarButton();
  93.             this.tbb4 = new System.Windows.Forms.ToolBarButton();
  94.             this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  95.             this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
  96.             this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
  97.             this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
  98.             this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
  99.             this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
  100.             this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
  101.             this.dataSet11 = new projekat.DataSet1();
  102.             this.naziv = new System.Windows.Forms.TextBox();
  103.             this.pdv = new System.Windows.Forms.TextBox();
  104.             this.dataSet21 = new projekat.DataSet2();
  105.             this.valuta = new System.Windows.Forms.DateTimePicker();
  106.             this.sqlDataAdapter2 = new System.Data.SqlClient.SqlDataAdapter();
  107.             this.sqlDeleteCommand2 = new System.Data.SqlClient.SqlCommand();
  108.             this.sqlInsertCommand2 = new System.Data.SqlClient.SqlCommand();
  109.             this.sqlSelectCommand2 = new System.Data.SqlClient.SqlCommand();
  110.             this.sqlUpdateCommand2 = new System.Data.SqlClient.SqlCommand();
  111.             this.button1 = new System.Windows.Forms.Button();
  112.             this.button2 = new System.Windows.Forms.Button();
  113.             this.comboBox1 = new System.Windows.Forms.ComboBox();
  114.             this.comboBox2 = new System.Windows.Forms.ComboBox();
  115.             this.label1 = new System.Windows.Forms.Label();
  116.             this.label2 = new System.Windows.Forms.Label();
  117.             this.label3 = new System.Windows.Forms.Label();
  118.             this.label4 = new System.Windows.Forms.Label();
  119.             this.label5 = new System.Windows.Forms.Label();
  120.             this.label6 = new System.Windows.Forms.Label();
  121.             ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
  122.             ((System.ComponentModel.ISupportInitialize)(this.dataSet21)).BeginInit();
  123.             this.SuspendLayout();
  124.             // 
  125.             // toolBar1
  126.             // 
  127.             this.toolBar1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  128.             this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
  129.                                                                                         this.tbb1,
  130.                                                                                         this.tbb2,
  131.                                                                                         this.tbb3,
  132.                                                                                         this.tbb4});
  133.             this.toolBar1.ButtonSize = new System.Drawing.Size(32, 31);
  134.             this.toolBar1.DropDownArrows = true;
  135.             this.toolBar1.ImageList = this.imageList1;
  136.             this.toolBar1.Location = new System.Drawing.Point(0, 0);
  137.             this.toolBar1.Name = "toolBar1";
  138.             this.toolBar1.ShowToolTips = true;
  139.             this.toolBar1.Size = new System.Drawing.Size(632, 38);
  140.             this.toolBar1.TabIndex = 0;
  141.             this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
  142.             // 
  143.             // tbb1
  144.             // 
  145.             this.tbb1.ImageIndex = 0;
  146.             this.tbb1.ToolTipText = "New";
  147.             // 
  148.             // tbb2
  149.             // 
  150.             this.tbb2.ImageIndex = 1;
  151.             this.tbb2.ToolTipText = "Save";
  152.             // 
  153.             // tbb3
  154.             // 
  155.             this.tbb3.ImageIndex = 2;
  156.             this.tbb3.ToolTipText = "Delete";
  157.             // 
  158.             // tbb4
  159.             // 
  160.             this.tbb4.ImageIndex = 3;
  161.             this.tbb4.ToolTipText = "Kraj";
  162.             // 
  163.             // imageList1
  164.             // 
  165.             this.imageList1.ImageSize = new System.Drawing.Size(20, 20);
  166.             this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
  167.             this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  168.             // 
  169.             // sqlDataAdapter1
  170.             // 
  171.             this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
  172.             this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
  173.             this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
  174.             this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
  175.                                                                                                       new System.Data.Common.DataTableMapping("Table", "faktura", new System.Data.Common.DataColumnMapping[] {
  176.                                                                                                                                                                                                                  new System.Data.Common.DataColumnMapping("idfak", "idfak"),
  177.                                                                                                                                                                                                                  new System.Data.Common.DataColumnMapping("iddob", "iddob"),
  178.                                                                                                                                                                                                                  new System.Data.Common.DataColumnMapping("naziv", "naziv"),
  179.                                                                                                                                                                                                                  new System.Data.Common.DataColumnMapping("valuta", "valuta"),
  180.                                                                                                                                                                                                                  new System.Data.Common.DataColumnMapping("pdv", "pdv")})});
  181.             this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
  182.             // 
  183.             // sqlDeleteCommand1
  184.             // 
  185.             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)";
  186.             this.sqlDeleteCommand1.Connection = this.sqlConnection1;
  187.             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));
  188.             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));
  189.             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));
  190.             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));
  191.             // 
  192.             // sqlConnection1
  193.             // 
  194.             this.sqlConnection1.ConnectionString = "workstation id=DEJAN;packet size=4096;integrated security=SSPI;data source=DEJAN;" +
  195.                 "persist security info=False;initial catalog=probna";
  196.             // 
  197.             // sqlInsertCommand1
  198.             // 
  199.             this.sqlInsertCommand1.CommandText = "INSERT INTO faktura(iddob, naziv, valuta, pdv) VALUES (@iddob, @naziv, @valuta, @" +
  200.                 "pdv); SELECT idfak, iddob, naziv, valuta, pdv FROM faktura WHERE (idfak = @@IDEN" +
  201.                 "TITY)";
  202.             this.sqlInsertCommand1.Connection = this.sqlConnection1;
  203.             this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@iddob", System.Data.SqlDbType.BigInt, 8, "iddob"));
  204.             this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@naziv", System.Data.SqlDbType.VarChar, 2147483647, "naziv"));
  205.             this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@valuta", System.Data.SqlDbType.DateTime, 8, "valuta"));
  206.             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));
  207.             // 
  208.             // sqlSelectCommand1
  209.             // 
  210.             this.sqlSelectCommand1.CommandText = "SELECT idfak, iddob, naziv, valuta, pdv FROM faktura";
  211.             this.sqlSelectCommand1.Connection = this.sqlConnection1;
  212.             // 
  213.             // sqlUpdateCommand1
  214.             // 
  215.             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)";
  216.             this.sqlUpdateCommand1.Connection = this.sqlConnection1;
  217.             this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@iddob", System.Data.SqlDbType.BigInt, 8, "iddob"));
  218.             this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@naziv", System.Data.SqlDbType.VarChar, 2147483647, "naziv"));
  219.             this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@valuta", System.Data.SqlDbType.DateTime, 8, "valuta"));
  220.             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));
  221.             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));
  222.             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));
  223.             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));
  224.             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));
  225.             this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@idfak", System.Data.SqlDbType.BigInt, 8, "idfak"));
  226.             // 
  227.             // dataSet11
  228.             // 
  229.             this.dataSet11.DataSetName = "DataSet1";
  230.             this.dataSet11.Locale = new System.Globalization.CultureInfo("en-GB");
  231.             // 
  232.             // naziv
  233.             // 
  234.             this.naziv.Anchor = System.Windows.Forms.AnchorStyles.Top;
  235.             this.naziv.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "faktura.naziv"));
  236.             this.naziv.Location = new System.Drawing.Point(168, 128);
  237.             this.naziv.Name = "naziv";
  238.             this.naziv.Size = new System.Drawing.Size(360, 20);
  239.             this.naziv.TabIndex = 4;
  240.             this.naziv.Text = "";
  241.             // 
  242.             // pdv
  243.             // 
  244.             this.pdv.Anchor = System.Windows.Forms.AnchorStyles.Top;
  245.             this.pdv.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "faktura.pdv"));
  246.             this.pdv.Location = new System.Drawing.Point(376, 168);
  247.             this.pdv.Name = "pdv";
  248.             this.pdv.Size = new System.Drawing.Size(48, 20);
  249.             this.pdv.TabIndex = 5;
  250.             this.pdv.Text = "";
  251.             this.pdv.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
  252.             // 
  253.             // dataSet21
  254.             // 
  255.             this.dataSet21.DataSetName = "DataSet2";
  256.             this.dataSet21.Locale = new System.Globalization.CultureInfo("en-GB");
  257.             // 
  258.             // valuta
  259.             // 
  260.             this.valuta.AccessibleRole = System.Windows.Forms.AccessibleRole.Window;
  261.             this.valuta.Anchor = System.Windows.Forms.AnchorStyles.Top;
  262.             this.valuta.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "faktura.valuta"));
  263.             this.valuta.Format = System.Windows.Forms.DateTimePickerFormat.Short;
  264.             this.valuta.ImeMode = System.Windows.Forms.ImeMode.HangulFull;
  265.             this.valuta.Location = new System.Drawing.Point(300, 80);
  266.             this.valuta.Name = "valuta";
  267.             this.valuta.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
  268.             this.valuta.Size = new System.Drawing.Size(92, 20);
  269.             this.valuta.TabIndex = 2;
  270.             this.valuta.Value = new System.DateTime(2009, 11, 26, 0, 0, 0, 0);
  271.             // 
  272.             // sqlDataAdapter2
  273.             // 
  274.             this.sqlDataAdapter2.DeleteCommand = this.sqlDeleteCommand2;
  275.             this.sqlDataAdapter2.InsertCommand = this.sqlInsertCommand2;
  276.             this.sqlDataAdapter2.SelectCommand = this.sqlSelectCommand2;
  277.             this.sqlDataAdapter2.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
  278.                                                                                                       new System.Data.Common.DataTableMapping("Table", "dobavljac", new System.Data.Common.DataColumnMapping[] {
  279.                                                                                                                                                                                                                    new System.Data.Common.DataColumnMapping("iddobavljac", "iddobavljac"),
  280.                                                                                                                                                                                                                    new System.Data.Common.DataColumnMapping("naziv", "naziv")})});
  281.             this.sqlDataAdapter2.UpdateCommand = this.sqlUpdateCommand2;
  282.             // 
  283.             // sqlDeleteCommand2
  284.             // 
  285.             this.sqlDeleteCommand2.CommandText = "DELETE FROM dobavljac WHERE (iddobavljac = @Original_iddobavljac) AND (naziv = @O" +
  286.                 "riginal_naziv OR @Original_naziv IS NULL AND naziv IS NULL)";
  287.             this.sqlDeleteCommand2.Connection = this.sqlConnection1;
  288.             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));
  289.             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));
  290.             // 
  291.             // sqlInsertCommand2
  292.             // 
  293.             this.sqlInsertCommand2.CommandText = "INSERT INTO dobavljac(naziv) VALUES (@naziv); SELECT iddobavljac, naziv FROM doba" +
  294.                 "vljac WHERE (iddobavljac = @@IDENTITY)";
  295.             this.sqlInsertCommand2.Connection = this.sqlConnection1;
  296.             this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@naziv", System.Data.SqlDbType.VarChar, 50, "naziv"));
  297.             // 
  298.             // sqlSelectCommand2
  299.             // 
  300.             this.sqlSelectCommand2.CommandText = "SELECT iddobavljac, naziv FROM dobavljac";
  301.             this.sqlSelectCommand2.Connection = this.sqlConnection1;
  302.             // 
  303.             // sqlUpdateCommand2
  304.             // 
  305.             this.sqlUpdateCommand2.CommandText = "UPDATE dobavljac SET naziv = @naziv WHERE (iddobavljac = @Original_iddobavljac) A" +
  306.                 "ND (naziv = @Original_naziv OR @Original_naziv IS NULL AND naziv IS NULL); SELEC" +
  307.                 "T iddobavljac, naziv FROM dobavljac WHERE (iddobavljac = @iddobavljac)";
  308.             this.sqlUpdateCommand2.Connection = this.sqlConnection1;
  309.             this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@naziv", System.Data.SqlDbType.VarChar, 50, "naziv"));
  310.             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));
  311.             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));
  312.             this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@iddobavljac", System.Data.SqlDbType.BigInt, 8, "iddobavljac"));
  313.             // 
  314.             // button1
  315.             // 
  316.             this.button1.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
  317.             this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image")));
  318.             this.button1.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
  319.             this.button1.Location = new System.Drawing.Point(192, 232);
  320.             this.button1.Name = "button1";
  321.             this.button1.Size = new System.Drawing.Size(64, 23);
  322.             this.button1.TabIndex = 2;
  323.             this.button1.TabStop = false;
  324.             this.button1.Text = "Next";
  325.             this.button1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  326.             this.button1.Click += new System.EventHandler(this.button1_Click);
  327.             // 
  328.             // button2
  329.             // 
  330.             this.button2.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
  331.             this.button2.Image = ((System.Drawing.Image)(resources.GetObject("button2.Image")));
  332.             this.button2.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
  333.             this.button2.Location = new System.Drawing.Point(328, 232);
  334.             this.button2.Name = "button2";
  335.             this.button2.Size = new System.Drawing.Size(64, 23);
  336.             this.button2.TabIndex = 7;
  337.             this.button2.TabStop = false;
  338.             this.button2.Text = "Prev";
  339.             this.button2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  340.             this.button2.Click += new System.EventHandler(this.button2_Click);
  341.             // 
  342.             // comboBox1
  343.             // 
  344.             this.comboBox1.Anchor = System.Windows.Forms.AnchorStyles.Top;
  345.             this.comboBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "faktura.idfak"));
  346.             this.comboBox1.DataSource = this.dataSet11;
  347.             this.comboBox1.DisplayMember = "faktura.idfak";
  348.             this.comboBox1.Location = new System.Drawing.Point(92, 80);
  349.             this.comboBox1.Name = "comboBox1";
  350.             this.comboBox1.Size = new System.Drawing.Size(84, 21);
  351.             this.comboBox1.TabIndex = 1;
  352.             this.comboBox1.ValueMember = "idfak";
  353.             // 
  354.             // comboBox2
  355.             // 
  356.             this.comboBox2.Anchor = System.Windows.Forms.AnchorStyles.Top;
  357.             this.comboBox2.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet21, "dobavljac.naziv"));
  358.             this.comboBox2.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.dataSet11, "faktura.iddob"));
  359.             this.comboBox2.DataSource = this.dataSet21.dobavljac;
  360.             this.comboBox2.DisplayMember = "naziv";
  361.             this.comboBox2.Location = new System.Drawing.Point(492, 80);
  362.             this.comboBox2.Name = "comboBox2";
  363.             this.comboBox2.Size = new System.Drawing.Size(121, 21);
  364.             this.comboBox2.TabIndex = 3;
  365.             this.comboBox2.ValueMember = "iddobavljac";
  366.             this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.promena);
  367.             // 
  368.             // label1
  369.             // 
  370.             this.label1.BackColor = System.Drawing.SystemColors.Info;
  371.             this.label1.Dock = System.Windows.Forms.DockStyle.Top;
  372.             this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  373.             this.label1.Location = new System.Drawing.Point(0, 38);
  374.             this.label1.Name = "label1";
  375.             this.label1.Size = new System.Drawing.Size(632, 23);
  376.             this.label1.TabIndex = 10;
  377.             this.label1.Text = "Faktura";
  378.             this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
  379.             // 
  380.             // label2
  381.             // 
  382.             this.label2.Anchor = System.Windows.Forms.AnchorStyles.Top;
  383.             this.label2.Location = new System.Drawing.Point(20, 80);
  384.             this.label2.Name = "label2";
  385.             this.label2.Size = new System.Drawing.Size(56, 20);
  386.             this.label2.TabIndex = 11;
  387.             this.label2.Text = "ID";
  388.             this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  389.             // 
  390.             // label3
  391.             // 
  392.             this.label3.Anchor = System.Windows.Forms.AnchorStyles.Top;
  393.             this.label3.Location = new System.Drawing.Point(244, 80);
  394.             this.label3.Name = "label3";
  395.             this.label3.Size = new System.Drawing.Size(40, 20);
  396.             this.label3.TabIndex = 12;
  397.             this.label3.Text = "Valuta";
  398.             this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  399.             // 
  400.             // label4
  401.             // 
  402.             this.label4.Anchor = System.Windows.Forms.AnchorStyles.Top;
  403.             this.label4.Location = new System.Drawing.Point(388, 80);
  404.             this.label4.Name = "label4";
  405.             this.label4.Size = new System.Drawing.Size(100, 20);
  406.             this.label4.TabIndex = 13;
  407.             this.label4.Text = "Costumers";
  408.             this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  409.             // 
  410.             // label5
  411.             // 
  412.             this.label5.Anchor = System.Windows.Forms.AnchorStyles.Top;
  413.             this.label5.Location = new System.Drawing.Point(112, 128);
  414.             this.label5.Name = "label5";
  415.             this.label5.Size = new System.Drawing.Size(40, 23);
  416.             this.label5.TabIndex = 14;
  417.             this.label5.Text = "Detail";
  418.             this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  419.             // 
  420.             // label6
  421.             // 
  422.             this.label6.Anchor = System.Windows.Forms.AnchorStyles.Top;
  423.             this.label6.Location = new System.Drawing.Point(312, 168);
  424.             this.label6.Name = "label6";
  425.             this.label6.Size = new System.Drawing.Size(48, 20);
  426.             this.label6.TabIndex = 15;
  427.             this.label6.Text = "Pdv";
  428.             this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  429.             // 
  430.             // Form1
  431.             // 
  432.             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  433.             this.ClientSize = new System.Drawing.Size(632, 273);
  434.             this.Controls.Add(this.label6);
  435.             this.Controls.Add(this.label5);
  436.             this.Controls.Add(this.label4);
  437.             this.Controls.Add(this.label3);
  438.             this.Controls.Add(this.label2);
  439.             this.Controls.Add(this.label1);
  440.             this.Controls.Add(this.comboBox2);
  441.             this.Controls.Add(this.comboBox1);
  442.             this.Controls.Add(this.button2);
  443.             this.Controls.Add(this.button1);
  444.             this.Controls.Add(this.valuta);
  445.             this.Controls.Add(this.pdv);
  446.             this.Controls.Add(this.naziv);
  447.             this.Controls.Add(this.toolBar1);
  448.             this.Name = "Form1";
  449.             this.Text = "Form1";
  450.             this.Load += new System.EventHandler(this.Form1_Load);
  451.             ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
  452.             ((System.ComponentModel.ISupportInitialize)(this.dataSet21)).EndInit();
  453.             this.ResumeLayout(false);
  454.  
  455.         }
  456.         #endregion
  457.  
  458.         /// <summary>
  459.         /// The main entry point for the application.
  460.         /// </summary>
  461.         [STAThread]
  462.         static void Main() 
  463.         {
  464.             Application.Run(new Form1());
  465.  
  466.         }
  467.  
  468.         private void Form1_Load(object sender, System.EventArgs e)
  469.         {
  470.             this.sqlDataAdapter1.Fill(this.dataSet11,0,0,"faktura");
  471.             this.sqlDataAdapter2.Fill(this.dataSet21,0,0,"dobavljac");
  472.  
  473. //            
  474.  
  475.  
  476.         }
  477.  
  478.  
  479.         private void button1_Click(object sender, System.EventArgs e)
  480.         {
  481.             this.BindingContext[this.dataSet11,"faktura"].Position++;
  482.  
  483. //                
  484.  
  485.             }
  486.  
  487.  
  488.         private void button2_Click(object sender, System.EventArgs e)
  489.         {
  490.             this.BindingContext[this.dataSet11,"faktura"].Position--;
  491.  
  492.         }
  493.  
  494.         private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
  495.         {
  496.             if (e.Button.ImageIndex==0)
  497.             {
  498.  
  499.                 this.BindingContext[this.dataSet11,"faktura"].AddNew();
  500.  
  501.  
  502.  
  503.             }
  504.             if (e.Button.ImageIndex==1)
  505.             {
  506.  
  507.                 this.BindingContext[this.dataSet11,"faktura"].EndCurrentEdit();
  508.  
  509.                 this.sqlDataAdapter1.Update(this.dataSet11,"faktura");
  510.  
  511.             }
  512.             if(e.Button.ImageIndex==2)
  513.             {
  514.                 int i=this.BindingContext[this.dataSet11,"faktura"].Position;
  515.                 this.BindingContext[this.dataSet11,"faktura"].RemoveAt(i);
  516.             }
  517.  
  518.         }
  519.  
  520.         private void promena(object sender, System.EventArgs e)
  521.         {
  522.             ComboBox cv=(ComboBox)sender;
  523.             if (cv.SelectedIndex==0)
  524.                 cv.SelectedIndex=-1;
  525.  
  526.         }
  527.  
  528.  
  529.  
  530.     }
  531. }
Nov 29 '09 #3
tlhintoq
3,525 Recognized Expert Specialist
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.
Nov 30 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: angelag | last post by:
I am currently taking a college course in Visual Basic.Net and I am a beginner. I bought Visual Studio.Net 2003 to do my homework at home. I built my first project and e-mailed it to myself at...
6
by: Martin Bless | last post by:
The good news: Along with Python-2.4 comes really good news to Windows users. Yes, you now CAN build extension modules yourself using the SAME C++ compiler and linker Python is built with...
0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
1
by: Daniel A. Thomas | last post by:
License required Maybe you don't have this but have one of the products that qualifies for the upgrade such as ... Visual Studio .NET 2003 Professional Visual Studio .NET 2003 Professional...
26
by: Bruno Jouhier [MVP] | last post by:
I'm currently experiencing a strange phenomenon: At my Office, Visual Studio takes a very long time to compile our solution (more than 1 minute for the first project). At home, Visual Studio...
9
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
9
by: Ed Crowley | last post by:
I have a DateTimePicker control on my form that is displaying the date format in UK format (dd/mm/yy). However, in my code dtpStartDate.Value gives a date in US format, but...
1
by: aaaa | last post by:
After this code: DateTimePicker1.Enable = false; The back color of the datetimepicker back color stay gray. I want it stay white. How can i do this??? Visual Studio 2003
2
by: =?Utf-8?B?QW5pcnVkZGhh?= | last post by:
Hi, I am building an windows application using Visual Studio 2005 (VB.NET). I would like to use a System.Windows.Forms.DateTimePicker. The default value is showing as syatem date. How can I show...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.