Exemple #1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         CigaretteDialog dialog = new CigaretteDialog();
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             int count = Convert.ToInt32(cigaretteTable.Compute("COUNT(CIGARETTECODE)", string.Format("CIGARETTECODE='{0}'", dialog.CigaretteCode)));
             if (count == 0)
             {
                 cigaretteDal.AddCigarette(dialog.CigaretteCode,dialog.ClassSymbol.ToUpper(),dialog.CigaretteName);
                 DataRow newRow = cigaretteTable.NewRow();
                 newRow["CIGARETTECODE"] = dialog.CigaretteCode;
                 newRow["CLASS"] = dialog.ClassSymbol;
                 newRow["CIGARETTENAME"] = dialog.CigaretteName;
                 cigaretteTable.Rows.InsertAt(newRow, 0);
             }
             else
                 THOKUtil.ShowInfo("�����Ѵ��ڣ����������롣");
         }
     }
     catch (Exception exp)
     {
         THOKUtil.ShowInfo("����������Ϣʧ��,ԭ��:" + exp.Message);
     }
 }
Exemple #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvMain.CurrentRow != null)
                {
                    DataRow row = ((DataRowView)dgvMain.CurrentRow.DataBoundItem).Row;
                    CigaretteDialog dialog = new CigaretteDialog(row);

                    if (dialog.ShowDialog() == DialogResult.OK)
                    {

                        cigaretteDal.SaveCigarette(dialog.CigaretteCode,dialog.ClassSymbol.ToUpper(),
                                    dialog.CigaretteName);
                        row["CLASS"] = dialog.ClassSymbol;
                        row["CIGARETTENAME"] = dialog.CigaretteName;
                    }
                }
            }
            catch (Exception exp)
            {
                THOKUtil.ShowInfo("�޸ľ�����Ϣʧ��,ԭ��:" + exp.Message);
            }
        }