/************************************************************* * 登録処理を行う *************************************************************/ private void executeAppend(CostAccountingEntities context) { int category = (int)Program.judgeCategory(radioBudget, radioActual); // 商品データの登録 var entityProduct = new Product() { year = Const.TARGET_YEAR, code = productCode.Text, category = category, type = (int)Const.PRODUCT_TYPE.Normal, item_code = itemCode.SelectedValue.ToString(), volume = Conversion.Parse(volume.Text), packing = packing.Text, note = note.Text, material_cost = Conversion.Parse(materialCost.Text), labor_cost = Conversion.Parse(laborCost.Text), labor_cost_direct = Conversion.Parse(laborCostDirect.Text), labor_cost_indirect = Conversion.Parse(laborCostIndirect.Text), contractors_cost = Conversion.Parse(contractorsCost.Text), manufacturing_cost = Conversion.Parse(manufacturingCost.Text), materials_fare = Conversion.Parse(materialsFare.Text), packing_cost = Conversion.Parse(packingCost.Text), machine_cost = Conversion.Parse(machineCost.Text), utilities_cost = Conversion.Parse(utilitiesCost.Text), other_cost = Conversion.Parse(otherCost.Text), product_cost = Conversion.Parse(productCost.Text), packing_fare = Conversion.Parse(packingFare.Text), selling_cost = Conversion.Parse(sellingCost.Text), management_cost = Conversion.Parse(managementCost.Text), overall_cost = Conversion.Parse(overallCost.Text), preprocess_time_m = Conversion.Parse(preprocessTimeM.Text), preprocess_time_f = Conversion.Parse(preprocessTimeF.Text), night_time_m = Conversion.Parse(nightTimeM_indirect.Text), night_time_f = Conversion.Parse(nightTimeF.Text), dry_time_m = Conversion.Parse(dryTimeM.Text), dry_time_f = Conversion.Parse(dryTimeF.Text), selection_time_m = Conversion.Parse(selectionTimeM.Text), selection_time_f = Conversion.Parse(selectionTimeF.Text), tray_num = Conversion.Parse(trayNum.Text), update_user = string.Concat(SystemInformation.ComputerName, "/", SystemInformation.UserName), update_date = DateTime.Now, del_flg = Const.FLG_OFF }; context.Product.Add(entityProduct); // 原料費データの登録 int no = 0; foreach (DataGridViewRow row in dgvMaterialCost.Rows) { string code = (string)row.Cells["dgvMaterialCostName"].Value; if (!String.IsNullOrEmpty(code)) { var entity = new ProductMaterial() { year = Const.TARGET_YEAR, product_code = productCode.Text, category = category, no = no++, code = code, quantity = Conversion.Parse((string)row.Cells["dgvMaterialCostQuantity"].Value), update_user = string.Concat(SystemInformation.ComputerName, "/", SystemInformation.UserName), update_date = DateTime.Now, del_flg = Const.FLG_OFF }; context.ProductMaterial.Add(entity); } } // 外注費データの登録 no = 0; foreach (DataGridViewRow row in dgvContractors.Rows) { string name = (string)row.Cells["dgvContractorsName"].Value; if (!String.IsNullOrEmpty(name)) { var entity = new ProductContractor() { year = Const.TARGET_YEAR, product_code = productCode.Text, category = category, no = no++, name = name, quantity = Conversion.Parse((string)row.Cells["dgvContractorsQuantity"].Value), cost = Conversion.Parse((string)row.Cells["dgvContractorsCost"].Value), update_user = string.Concat(SystemInformation.ComputerName, "/", SystemInformation.UserName), update_date = DateTime.Now, del_flg = Const.FLG_OFF }; context.ProductContractor.Add(entity); } } // 原料運賃データの登録 no = 0; foreach (DataGridViewRow row in dgvMaterialsFare.Rows) { string name = (string)row.Cells["dgvMaterialsFareName"].Value; if (!String.IsNullOrEmpty(name)) { var entity = new ProductMaterialsFare() { year = Const.TARGET_YEAR, product_code = productCode.Text, category = category, no = no++, name = name, quantity = Conversion.Parse((string)row.Cells["dgvMaterialsFareQuantity"].Value), cost = Conversion.Parse((string)row.Cells["dgvMaterialsFareCost"].Value), update_user = string.Concat(SystemInformation.ComputerName, "/", SystemInformation.UserName), update_date = DateTime.Now, del_flg = Const.FLG_OFF }; context.ProductMaterialsFare.Add(entity); } } // 包装資材費データの登録 no = 0; foreach (DataGridViewRow row in dgvPacking.Rows) { string code = (string)row.Cells["dgvPackingName"].Value; if (!String.IsNullOrEmpty(code)) { var entity = new ProductPacking() { year = Const.TARGET_YEAR, product_code = productCode.Text, category = category, no = no++, code = code, quantity = Conversion.Parse((string)row.Cells["dgvPackingQuantity"].Value), update_user = string.Concat(SystemInformation.ComputerName, "/", SystemInformation.UserName), update_date = DateTime.Now, del_flg = Const.FLG_OFF }; context.ProductPacking.Add(entity); } } // 設備費データの登録 no = 0; foreach (DataGridViewRow row in dgvMachine.Rows) { string code = (string)row.Cells["dgvMachineName"].Value; if (!String.IsNullOrEmpty(code)) { var entity = new ProductMachine() { year = Const.TARGET_YEAR, product_code = productCode.Text, category = category, no = no++, code = code, time = Conversion.Parse((string)row.Cells["dgvMachineTime"].Value), update_user = string.Concat(SystemInformation.ComputerName, "/", SystemInformation.UserName), update_date = DateTime.Now, del_flg = Const.FLG_OFF }; context.ProductMachine.Add(entity); } } /** 2016.4.30 荷造運賃は取引先単位に登録できるように修正を行う。 start---- // 荷造運賃 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); } } ----end */ }
/************************************************************* * 登録処理を行う *************************************************************/ private void executeAppend(CostAccountingEntities context) { int category = (int)Program.judgeCategory(radioBudget, radioActual); // 商品データの登録 var entityProduct = new Product() { year = Const.TARGET_YEAR, code = productCode.Text, category = category, type = (int)Const.PRODUCT_TYPE.Blend, item_code = itemCode.SelectedValue.ToString(), packing = packing.Text, note = note.Text, material_cost = Conversion.Parse(materialCost.Text), labor_cost = Conversion.Parse(laborCost.Text), labor_cost_direct = Conversion.Parse(laborCostDirect.Text), labor_cost_indirect = Conversion.Parse(laborCostIndirect.Text), contractors_cost = Conversion.Parse(contractorsCost.Text), manufacturing_cost = Conversion.Parse(manufacturingCost.Text), materials_fare = Conversion.Parse(materialsFare.Text), packing_cost = Conversion.Parse(packingCost.Text), machine_cost = Conversion.Parse(machineCost.Text), utilities_cost = Conversion.Parse(utilitiesCost.Text), other_cost = Conversion.Parse(otherCost.Text), product_cost = Conversion.Parse(productCost.Text), packing_fare = Conversion.Parse(packingFare.Text), selling_cost = Conversion.Parse(sellingCost.Text), management_cost = Conversion.Parse(managementCost.Text), overall_cost = Conversion.Parse(overallCost.Text), update_user = string.Concat(SystemInformation.ComputerName, "/", SystemInformation.UserName), update_date = DateTime.Now, del_flg = Const.FLG_OFF }; context.Product.Add(entityProduct); // ブレンドする商品データの登録 int no = 0; foreach (DataGridViewRow row in dgvProduct.Rows) { string code = (string)row.Cells["dgvProductCode"].Value; if (!String.IsNullOrEmpty(code)) { string rateStr = (string)row.Cells["dgvBlendRate"].Value; if (!string.IsNullOrEmpty(rateStr)) { rateStr = rateStr.Replace("%", ""); } decimal rate = decimal.Divide(Conversion.Parse(rateStr), 100); var entity = new ProductBlend() { year = Const.TARGET_YEAR, product_code = productCode.Text, category = category, no = no++, code = code, blend_rate = rate, update_user = string.Concat(SystemInformation.ComputerName, "/", SystemInformation.UserName), update_date = DateTime.Now, del_flg = Const.FLG_OFF }; context.ProductBlend.Add(entity); } } }