Ejemplo n.º 1
0
 private void Open()
 {
     try
     {
         int id = SelectedId;
         if (id != 0)
         {
             Product product = null;
             using (GmConnection conn = App.CreateConnection())
             {
                 product = Product.GetProduct(conn, id);
             }
             if (product != null)
             {
                 ProductForm form = new ProductForm(product);
                 if (form.ShowDialog() == DialogResult.OK)
                 {
                     UpdateRow(SelectedRow, form);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
 }
Ejemplo n.º 2
0
 private void UpdateRow(DataRow dr, ProductForm form)
 {
     if (dr != null)
     {
         Product product = form.Product;
         dr["Id"]             = product.Id;
         dr["Code"]           = product.code;
         dr["Name"]           = product.name;
         dr["PackedNumber"]   = product.packedNumber;
         dr["MedicamentId"]   = product.medicamentId;
         dr["MedicamentName"] = form.MedicamentName;
         dr["Maker"]          = product.maker;
         dr["BaseUnitId"]     = product.baseUnitId;
         dr["BaseUnitName"]   = form.BaseUnitName;
         dr["UnitCount"]      = product.unitCount;
     }
 }
Ejemplo n.º 3
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         Product     user = new Product();
         ProductForm form = new ProductForm(user);
         if (form.ShowDialog() == DialogResult.OK)
         {
             DataRow newRow = dataTable.NewRow();
             dataTable.Rows.Add(newRow);
             UpdateRow(newRow, form);
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
 }