Esempio n. 1
0
 private void AssignNewCrafts(ProductCrafts item)
 {
     if (item == null) return;
     if (!crafts.ContainsKey(item.CraftsID)) return;
     ProductCrafts oldItem = crafts[item.CraftsID];
     oldItem.CraftsName = item.CraftsName;
     oldItem.Remark = item.Remark;
 }
Esempio n. 2
0
 private ProductCrafts GetProductCraftsFrom(DataRow row)
 {
     if (row == null) return null;
     ProductCrafts pc = new ProductCrafts();
     pc.CraftsID = Formatter.GetStringValueFrom(row, "CraftsID");
     pc.CraftsName = Formatter.GetStringValueFrom(row, "CraftsName");
     pc.Remark = Formatter.GetStringValueFrom(row, "Remark");
     return pc;
 }
Esempio n. 3
0
 public ProductCrafts UpdateCrafts(ProductCrafts craft)
 {
     if (craft == null) return null;
     try
     {
         DataSet ds = SqlHelper.ExecuteDataset(sqlConn, "UpdateProductCrafts", new object[] { currentUser.UserID, craft.CraftsID, craft.CraftsName, craft.Remark });
         if (ds != null && ds.Tables != null && ds.Tables.Count > 0)
         {
             DataTable table = ds.Tables[0];
             ProductCrafts pc = GetProductCraftsFrom(table.Rows[0]);
             if (pc != null)
             {
                 if (!crafts.ContainsKey(pc.CraftsID))
                     crafts[pc.CraftsID] = pc;
                 else AssignNewCrafts(pc);
                 return pc;
             }
         }
     }
     catch (Exception ex)
     {
         LoggerBase.Instance.Error(ex.ToString());
     }
     return null;
 }
Esempio n. 4
0
 private void btn_New_Click(object sender, EventArgs e)
 {
     NewParameter form = new NewParameter();
     if (form.ShowDialog(this) == DialogResult.OK)
     {
         bool ok = false;
         int i = cbx_ParamName.SelectedIndex;
         string paramName = form.ParameterName;
         string paramRemark = form.ParameterRemark;
         switch (cbx_ParamType.SelectedIndex)
         {
             case 0:
                 //Category
                 ProductCategory category = new ProductCategory();
                 category.CategoryName = paramName;
                 category.Remark = paramRemark;
                 ok = (DataService.Instance.CreateCategory(category) != null);
                 if (ok)
                 {
                     cbx_ParamName.Items.Clear();
                     cbx_ParamName.Items.AddRange(DataService.Instance.Categories.ToArray());
                 }
                 break;
             case 1:
                 //Sub Category
                 ProductSubCategory subCategory = cbx_ParamName.SelectedItem as ProductSubCategory;
                 if (subCategory != null)
                 {
                     ProductSubCategory newSubCate = new ProductSubCategory();
                     newSubCate.CategoryID = subCategory.CategoryID;
                     newSubCate.Remark = paramRemark;
                     newSubCate.SubCategoryName = paramName;
                     ok = (DataService.Instance.CreateSubCategory(newSubCate) != null);
                     if (ok)
                     {
                         cbx_ParamName.Items.Clear();
                         cbx_ParamName.Items.AddRange(DataService.Instance.SubCategories.ToArray());
                     }
                 }
                 break;
             case 2:
                 //Color
                 ProductColor color = new ProductColor();
                 color.ColorName = paramName;
                 color.Remark = paramRemark;
                 ok = (DataService.Instance.CreateColor(color) != null);
                 if (ok)
                 {
                     cbx_ParamName.Items.Clear();
                     cbx_ParamName.Items.AddRange(DataService.Instance.Colors.ToArray());
                 }
                 break;
             case 3:
                 //Crafts
                 ProductCrafts crafts = new ProductCrafts();
                 crafts.CraftsName = paramName;
                 crafts.Remark = paramRemark;
                 ok = (DataService.Instance.CreateCrafts(crafts) != null);
                 if (ok)
                 {
                     cbx_ParamName.Items.Clear();
                     cbx_ParamName.Items.AddRange(DataService.Instance.Crafts.ToArray());
                 }
                 break;
             case 4:
                 //Material
                 ProductMaterial material = new ProductMaterial();
                 material.MaterialName = paramName;
                 material.Remark = paramRemark;
                 ok = (DataService.Instance.CreateMaterial(material) != null);
                 if (ok)
                 {
                     cbx_ParamName.Items.Clear();
                     cbx_ParamName.Items.AddRange(DataService.Instance.Materials.ToArray());
                 }
                 break;
             default:
                 break;
         }
         if (!ok)
         {
             MessageBox.Show(ResourceHelper.Instance.GetString("NewParameter.New.Failed"), Text);
         }
         else
         {
             if (cbx_ParamName.Items.Count > i)
                 cbx_ParamName.SelectedIndex = i;
         }
     }
 }