コード例 #1
0
ファイル: UpdateDA.cs プロジェクト: faksam/My_FPT_C-Sharp
        public static void SupplierUpdate(SupplierCL a)
        {
            try
            {
                string cm = "Update Suppliers set CompanyName = @CompanyName,ContactName = @ContactName, Address=@Address,Phone=@Phone,Fax=@Fax " + "where SupplierID = " + a.SupplierID;
                SqlCommand cmd = new SqlCommand(cm, con);

                cmd.Parameters.AddWithValue("@SupplierID", a.SupplierID);
                cmd.Parameters.AddWithValue("@CompanyName", a.ComName);
                cmd.Parameters.AddWithValue("@ContactName", a.ConName);
                cmd.Parameters.AddWithValue("@Address", a.Address);
                cmd.Parameters.AddWithValue("@Phone", a.Phone);
                cmd.Parameters.AddWithValue("@Fax", a.Fax);

                con.Open();

                cmd.ExecuteNonQuery();
                con.Close();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
        }
コード例 #2
0
ファイル: AdminGUI.cs プロジェクト: faksam/My_FPT_C-Sharp
 private void btEdit_Click(object sender, EventArgs e)
 {
     if (btEdit.Text == "Edit")
     {
         EnableTextBox(true);
         tbSupID.Enabled = false;
         btEdit.Text = "Save";
         btAdd.Enabled = false;
         btDelete.Enabled = false;
     }
     else
     {
         if (tbComName.Text == "")
         {
             MessageBox.Show("Company name must be fill");
         }
         else
         {
             SupplierCL sup = new SupplierCL();
             try
             {
                 sup.SupplierID = int.Parse(tbSupID.Text.Trim());
                 sup.ComName = tbComName.Text;
                 sup.ConName = tbConName.Text;
                 sup.Address = tbAddress.Text;
                 sup.Phone = tbPhone.Text;
                 sup.Fax = tbFax.Text;
                 UpdateDA.SupplierUpdate(sup);
                 ClearTextBox();
                 EnableTextBox(false);
                 btEdit.Text = "Edit";
                 btAdd.Enabled = true;
                 btDelete.Enabled = true;
                 showData("");
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Company Name must be filled");
             }
         }
     }
 }
コード例 #3
0
ファイル: AdminGUI.cs プロジェクト: faksam/My_FPT_C-Sharp
 private void btAdd_Click(object sender, EventArgs e)
 {
     if (btAdd.Text == "Add")
     {
         int a = SelectDA.GetMax("SupplierID", "Suppliers") + 1;
         ClearTextBox();
         EnableTextBox(true);
         dgvSupplier.DataSource = null;
         tbSupID.Enabled = false;
         tbSupID.Text = a.ToString();
         btAdd.Text = "Save";
         btEdit.Enabled = false;
         btDelete.Enabled = false;
     }
     else
     {
         if (tbComName.Text == "")
         {
             MessageBox.Show("Company Name must be fill");
         }
         else
         {
             SupplierCL sup = new SupplierCL();
             try
             {
                 sup.SupplierID = int.Parse(tbSupID.Text.Trim());
                 sup.ComName = tbComName.Text;
                 sup.ConName = tbConName.Text;
                 sup.Address = tbAddress.Text;
                 sup.Phone = tbPhone.Text;
                 sup.Fax = tbFax.Text;
                 InsertDA.insertSupplier(sup);
                 ClearTextBox();
                 EnableTextBox(false);
                 btAdd.Text = "Add";
                 btEdit.Enabled = true;
                 btDelete.Enabled = true;
                 showData("");
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Company Name must be filled");
             }
         }
     }
 }
コード例 #4
0
ファイル: InsertDA.cs プロジェクト: faksam/My_FPT_C-Sharp
        public static void insertSupplier(SupplierCL a)
        {
            try
            {

                SqlCommand cmd = new SqlCommand("SET IDENTITY_INSERT Suppliers ON Insert into Suppliers" +
                    "(SupplierID,CompanyName,ContactName,Address,Phone,Fax) " +
                    "values(@SupplierID,@CompanyName,@ContactName,@Address,@Phone,@Fax)", con);
                cmd.Parameters.AddWithValue("@SupplierID", a.SupplierID);
                cmd.Parameters.AddWithValue("@CompanyName", a.ComName);
                cmd.Parameters.AddWithValue("@ContactName", a.ConName);
                cmd.Parameters.AddWithValue("@Address", a.Address);
                cmd.Parameters.AddWithValue("@Phone", a.Phone);
                cmd.Parameters.AddWithValue("@Fax", a.Fax);

                con.Open();

                cmd.ExecuteNonQuery();
                con.Close();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
        }