private BillOfMaterialDetail GetDataDetail() { BillOfMaterialDetail entity = new BillOfMaterialDetail(); entity.bill_of_material_detail_id = keyCodeDetail; entity.bill_of_material_head_id = Converts.ParseLong(keyCode); if (modeDetail == ObjectState.Add) { entity.material_id = Converts.ParseLongNullable(ddlMaterial.SelectedValue.ToString()); entity.bill_of_material_head_id_sub = Converts.ParseLongNullable(ddlBOMDetail.SelectedValue.ToString()); entity.amount = Converts.ParseDecimalNullable(txtAmount.Text); entity.IsCheckedMaterial = rdbMaterial.Checked; entity.lost_factor = 0; entity.created_by = "SYSTEM"; entity.created_date = DateTime.Now; entity.updated_by = "SYSTEM"; entity.updated_date = DateTime.Now; } else { entity = ServiceProvider.BillOfMaterialDetailService.FindByKeys(entity, false); if (entity != null) { entity.material_id = Converts.ParseLongNullable(ddlMaterial.SelectedValue.ToString()); entity.bill_of_material_head_id_sub = Converts.ParseLongNullable(ddlBOMDetail.SelectedValue.ToString()); entity.amount = Converts.ParseDecimalNullable(txtAmount.Text); entity.IsCheckedMaterial = rdbMaterial.Checked; entity.updated_by = "SYSTEM"; entity.updated_date = DateTime.Now; } } return entity; }
private void LoadDataDetail(long BOMDetailID) { ddlMaterial.DataSource = ServiceProvider.MaterialService.GetMaterialComboBoxDTO(); ddlMaterial.ValueMember = "Value"; ddlMaterial.DisplayMember = "Display"; ddlBOMDetail.DataSource = ServiceProvider.BillOfMaterialHeadService.GetBillOfMaterialHeadComboBoxDTOByID(null); ddlBOMDetail.ValueMember = "Value"; ddlBOMDetail.DisplayMember = "Display"; BillOfMaterialDetail entity = new BillOfMaterialDetail(); if (modeDetail == ObjectState.Edit && BOMDetailID != 0) { //---Detail entity.bill_of_material_detail_id = BOMDetailID; entity = ServiceProvider.BillOfMaterialDetailService.FindByKeys(entity, true); if (entity != null) { if (entity.material_id != null) { rdbMaterial.Checked = true; rdbBOM.Checked = false; ddlMaterial.Enabled = true; ddlBOMDetail.Enabled = false; ddlMaterial.SelectedValue = entity.material_id.ToString(); GetUOM(); } else { rdbMaterial.Checked = false; rdbBOM.Checked = true; ddlMaterial.Enabled = false; ddlBOMDetail.Enabled = true; ddlBOMDetail.SelectedValue = entity.bill_of_material_head_id_sub.ToString(); } txtAmount.Text = string.Format(Format.IntegerNumberFormatNoZero, entity.amount); keyCodeDetail = entity.bill_of_material_detail_id; } } else { keyCodeDetail = 0; rdbMaterial.Checked = true; rdbBOM.Checked = false; ddlMaterial.Enabled = true; ddlBOMDetail.Enabled = false; ddlMaterial.SelectedIndex = 0; txtUOM.Text = string.Empty; ddlBOMDetail.SelectedIndex = 0; txtAmount.Text = string.Empty; } grdDetail.LoadData(); }