/************************************************************* * 取引先の修正処理を行う *************************************************************/ private void executeChangeSupplier(CostAccountingEntities context) { int category = (int)Program.judgeCategory(radioBudget, radioActual); var target = from t in context.ProductSupplier where t.year.Equals(Const.TARGET_YEAR) && t.product_code.Equals(productCode.Text) && t.supplier_code.Equals(suppllierCode.Text) && t.category.Equals(category) && t.type.Equals((int)Const.PRODUCT_TYPE.Normal) select t; if (target.Count() > decimal.Zero) { target.First().unit_price = Conversion.Parse(unitPrice.Text); target.First().update_user = string.Concat(SystemInformation.ComputerName, "/", SystemInformation.UserName); target.First().update_date = DateTime.Now; } // 荷造運賃データは、削除→登録により修正とみなす。 // 削除 var packingFare = from t in context.ProductPackingFare where t.year.Equals(Const.TARGET_YEAR) && t.product_code.Equals(productCode.Text) && t.supplier_code.Equals(suppllierCode.Text) && t.category.Equals(category) select t; context.ProductPackingFare.RemoveRange(packingFare); // 登録 int no = 0; foreach (DataGridViewRow row in dgvPackingFare.Rows) { string code = (string)row.Cells["dgvPackingFareName"].Value; if (!String.IsNullOrEmpty(code)) { var entity = new ProductPackingFare() { year = Const.TARGET_YEAR, product_code = productCode.Text, supplier_code = suppllierCode.Text, category = category, no = no++, code = code, quantity = Conversion.Parse((string)row.Cells["dgvPackingFareQuantity"].Value), update_user = string.Concat(SystemInformation.ComputerName, "/", SystemInformation.UserName), update_date = DateTime.Now, del_flg = Const.FLG_OFF }; context.ProductPackingFare.Add(entity); } } }
/************************************************************* * 取引先の登録処理を行う *************************************************************/ private void executeAppendSupplier(CostAccountingEntities context) { int category = (int)Program.judgeCategory(radioBudget, radioActual); // 取引先データの登録 var entitySupplier = new ProductSupplier() { year = Const.TARGET_YEAR, product_code = productCode.Text, supplier_code = suppllierCode.Text, category = category, type = (int)Const.PRODUCT_TYPE.Normal, unit_price = Conversion.Parse(unitPrice.Text), update_user = string.Concat(SystemInformation.ComputerName, "/", SystemInformation.UserName), update_date = DateTime.Now, del_flg = Const.FLG_OFF }; context.ProductSupplier.Add(entitySupplier); // 荷造運賃 int no = 0; foreach (DataGridViewRow row in dgvPackingFare.Rows) { string code = (string)row.Cells["dgvPackingFareName"].Value; if (!String.IsNullOrEmpty(code)) { var entity = new ProductPackingFare() { year = Const.TARGET_YEAR, product_code = productCode.Text, supplier_code = suppllierCode.Text, category = category, no = no++, code = code, quantity = Conversion.Parse((string)row.Cells["dgvPackingFareQuantity"].Value), update_user = string.Concat(SystemInformation.ComputerName, "/", SystemInformation.UserName), update_date = DateTime.Now, del_flg = Const.FLG_OFF }; context.ProductPackingFare.Add(entity); } } }