public MappingLookupModel GetByID(MappingLookupModel model) { string sql = string.Format(@"SELECT * FROM ucc_ic_MappingLookUp (NOLOCK) WHERE typeCode = '{0}' AND supplierCode = '{1}' AND SupCode = '{2}' Order by SupCode asc", model.TypeCode, model.SupplierCode, model.SupCode); return Repository.Instance.GetOne<MappingLookupModel>(sql); }
public MappingCustomerDialog(string supplierCode, string supplierName, string source) { InitializeComponent(); this._repo = new LookupRepo(); this.HeadContent = new MappingLookupModel(); HeadContent.SupplierCode = supplierCode; HeadContent.SupplierName = supplierName; HeadContent.SupCode = source; }
public IEnumerable<MappingLookupModel> GetByFilter(MappingLookupModel model) { IEnumerable<MappingLookupModel> query = GetAll(model.TypeCode, model.SupplierCode); if (model.SupCode != null) { query = query.Where(p => p.SupCode.Contains(model.SupCode.ToString())); } if (model.UCCCode != null) { query = query.Where(p => p.UCCCode.Contains(model.UCCCode.ToString())); } return query; }
public IEnumerable<MappingLookupModel> Delete(MappingLookupModel model) { string sql = string.Format(@"DELETE FROM ucc_ic_MappingLookUp WHERE LookupID = {0} " + Environment.NewLine , model.LookupID); Repository.Instance.ExecuteWithTransaction(sql, "Delete Lookup Mapping"); return GetAll(model.TypeCode, model.SupplierCode); }
public IEnumerable<MappingLookupModel> Save(MappingLookupModel model) { string sql = string.Format(@"IF NOT EXISTS ( SELECT * FROM ucc_ic_MappingLookUp (NOLOCK) WHERE typeCode = '{0}' AND supplierCode = '{1}' AND SupCode = '{2}' ) BEGIN INSERT INTO ucc_ic_MappingLookUp (TypeCode ,SupplierCode ,SupCode ,UCCCode ,ActiveFlag ,UCCCodeForeign) VALUES ('{0}' --<TypeCode, nvarchar(50),> ,N'{1}' --<SupplierCode, nvarchar(100),> ,N'{2}' --<SupCode, nvarchar(100),> ,N'{3}' --<UCCCode, nvarchar(100),> ,{4} --<ActiveFlag, tinyint,>) ,N'{5}' ) END ELSE BEGIN UPDATE ucc_ic_MappingLookUp SET UCCCode = N'{3}' --<Quantity, decimal(15,2),> , UCCCodeForeign = N'{5}' WHERE typeCode = '{0}' AND supplierCode = '{1}' AND SupCode = '{2}' END " + Environment.NewLine , model.TypeCode , model.SupplierCode , model.SupCode , model.UCCCode , 1 , model.UCCCodeForeign ); Repository.Instance.ExecuteWithTransaction(sql, "Update Lookup Mapping"); return GetAll(model.TypeCode, model.SupplierCode); }
private void butAdd_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSource.Text)) { MessageBox.Show("Please fill the source data.", "Data not valid.", MessageBoxButtons.OK, MessageBoxIcon.Error); txtSource.Focus(); return; } if (string.IsNullOrEmpty(txtCustID.Text)) { MessageBox.Show("Please fill the customer data.", "Data not valid.", MessageBoxButtons.OK, MessageBoxIcon.Error); txtSource.Focus(); return; } MappingLookupModel model = new MappingLookupModel(); model.TypeCode = "CUST"; model.SupplierCode = HeadContent.SupplierCode; model.SupCode = txtSource.Text.Trim(); model.UCCCode = txtCustID.Text.Trim(); model.UCCCodeForeign = string.Empty; var result = _repo.Save(model); SetGrid(result); }
/// <summary> /// For ITAKU /// </summary> /// <param name="grid"> DataGridView Name</param> /// <returns></returns> private bool ValidateGridCell(ref DataGridView grid) { lblValidation.Text = ""; bool error = false; //Mapping data header for Maker and Customer //1. Check Maker if (string.IsNullOrEmpty(HeadContent.MakerName)) { var result = _repoMaker.GetByID(HeadContent.MakerCode); if (result == null) { MappingLookupModel model = new MappingLookupModel(); model.TypeCode = "MAKER"; model.SupplierCode = HeadContent.SupplierCode; model.SupCode = txtMakerCode.Text.Trim(); var lookupResult = _repoLookup.GetByID(model); if (lookupResult != null) { HeadContent.MakerCode = lookupResult.UCCCode; var makerrow = _repoMaker.GetByID(HeadContent.MakerCode); HeadContent.MakerName = makerrow.MakerName; } else { errorProvider1.SetError(txtMakerCode, "This Maker Code dosen't exist in the system."); lblValidation.Text = "This Maker Code dosen't exist in the system."; txtMakerCode.Focus(); return true; } } else { HeadContent.MakerCode = result.MakerCode; HeadContent.MakerName = result.MakerName; } } //2. Check Customer if (string.IsNullOrEmpty(HeadContent.CustomerName)) { var result = _repoCust.GetCustomerByID(HeadContent.CustID); if (result == null) { MappingLookupModel model = new MappingLookupModel(); model.TypeCode = "CUST"; model.SupplierCode = HeadContent.SupplierCode; model.SupCode = txtCustID.Text.Trim(); var lookupResult = _repoLookup.GetByID(model); if (lookupResult != null) { HeadContent.CustID = lookupResult.UCCCode; var custRow = _repoCust.GetCustomerByID(HeadContent.CustID); HeadContent.CustomerName = custRow.CustName; } else { errorProvider1.SetError(txtCustID, "This Customer Code dosen't exist in the system."); lblValidation.Text = "This Customer Code dosen't exist in the system."; txtCustID.Focus(); return true; } } else { HeadContent.CustID = result.CustId; HeadContent.CustomerName = result.CustName; } } //Set header content SetHeaderContent(HeadContent); for (int i = 0; (grid.Rows.Count) > i; i++) { if (string.IsNullOrEmpty(grid.Rows[i].Cells["id1"].Value.GetString())) return error; CommodityModel CommodityByRow = new CommodityModel(); SpecModel SpecByRow = new SpecModel(); CoatingModel CoatingByRow = new CoatingModel(); WharehouseModel WhseByRow = new WharehouseModel(); for (int j = 0; (grid.Columns.Count) > j; j++) { try { //Article Duplicate if (grid.Columns[j].Name == "article") { if (string.IsNullOrEmpty(grid[j, i].Value.GetString())) { grid.CurrentCell = grid[j, i]; lblValidation.Text = "Please fill data on current focus."; return true; } else if (_repo.CheckArticleExisting(grid.Rows[i].Cells["article"].Value.GetString(), Convert.ToInt32(grid.Rows[i].Cells["id1"].Value.GetString().GetInt()))) { grid.CurrentCell = grid[j, i]; lblValidation.Text = "This Article number is duplicate."; return true; } else { lblValidation.Text = ""; } } //Commodity validation if (grid.Columns[j].Name == "commodity1") { if (string.IsNullOrEmpty(grid[j, i].Value.GetString())) { grid.CurrentCell = grid[j, i]; lblValidation.Text = "Please fill data on current focus."; return true; } CommodityByRow = _repoCmdt.GetByID(grid.Rows[i].Cells["commodity1"].Value.GetString()); if (CommodityByRow == null) { grid.CurrentCell = grid[j, i]; lblValidation.Text = "This Commodity Code dosen't exist in the system."; return true; } else { lblValidation.Text = ""; } } //Specification depend on commodity if (grid.Columns[j].Name == "spec1") { if (string.IsNullOrEmpty(grid[j, i].Value.GetString())) { grid.CurrentCell = grid[j, i]; lblValidation.Text = "Please fill data on current focus."; return true; } SpecByRow = _repoSpec.GetByID(grid.Rows[i].Cells["spec1"].Value.GetString(), CommodityByRow.CommodityCode); if (SpecByRow == null) { MappingLookupModel model = new MappingLookupModel(); model.TypeCode = "SPEC"; model.SupplierCode = HeadContent.SupplierCode; model.SupCode = grid.Rows[i].Cells["spec1"].Value.GetString().Trim(); var result = _repoLookup.GetByID(model); if (result != null) { grid.Rows[i].Cells["spec1"].Value = result.UCCCode; grid.Rows[i].Cells["specname"].Value = _repoSpec.GetByID(result.UCCCode, result.UCCCodeForeign).SpecName; grid.Rows[i].Cells["commodity1"].Value = result.UCCCodeForeign; grid.Rows[i].Cells["cmdtname"].Value = _repoCmdt.GetByID(result.UCCCodeForeign).CommodityName; } } SpecByRow = _repoSpec.GetByID(grid.Rows[i].Cells["spec1"].Value.GetString(), CommodityByRow.CommodityCode); if (SpecByRow == null) { grid.CurrentCell = grid[j, i]; lblValidation.Text = "This Spec Code dosen't exist in the system or not relate with Commodity Code."; return true; } else { lblValidation.Text = ""; } } //Commodity require coating if (grid.Columns[j].Name == "Coating") { if (string.IsNullOrEmpty(grid[j, i].Value.GetString()) && CommodityByRow.CoatingRequire) { grid.CurrentCell = grid[j, i]; lblValidation.Text = "Commodity [" + CommodityByRow.CommodityName + "] is require coating."; return true; } if (!string.IsNullOrEmpty(grid[j, i].Value.GetString())) { CoatingByRow = _repoCoating.GetByID(grid.Rows[i].Cells["Coating"].Value.GetString()); if (CoatingByRow == null) { grid.CurrentCell = grid[j, i]; lblValidation.Text = "This Coating dosen't exist in the system."; return true; } else { lblValidation.Text = ""; } } } //Thick if (grid.Columns[j].Name == "thick") { decimal tp; if (!decimal.TryParse(Convert.ToString(grid.Rows[i].Cells["thick"].Value.GetString()), out tp)) { grid.CurrentCell = grid[j, i]; lblValidation.Text = "Please enter numeric."; return true; } else if (Convert.ToString(grid.Rows[i].Cells["thick"].Value.GetString()) == "0") { grid.CurrentCell = grid[j, i]; lblValidation.Text = "Can't fill be zero."; return true; } else { lblValidation.Text = ""; } } //Width if (grid.Columns[j].Name == "width") { decimal tp; if (!decimal.TryParse(Convert.ToString(grid.Rows[i].Cells["width"].Value.GetString()), out tp)) { grid.CurrentCell = grid[j, i]; lblValidation.Text = "Please enter numeric."; return true; } else if (Convert.ToString(grid.Rows[i].Cells["width"].Value.GetString()) == "0") { grid.CurrentCell = grid[j, i]; lblValidation.Text = "Can't fill be zero."; return true; } else { lblValidation.Text = ""; } } //Length if (grid.Columns[j].Name == "length") { decimal tp; if (!decimal.TryParse(Convert.ToString(grid.Rows[i].Cells["length"].Value.GetString()), out tp)) { grid.CurrentCell = grid[j, i]; lblValidation.Text = "Please enter numeric."; return true; } else { lblValidation.Text = ""; } } //Quantity if (grid.Columns[j].Name == "quantity2") { decimal tp; if (!decimal.TryParse(Convert.ToString(grid.Rows[i].Cells["quantity2"].Value.GetString()), out tp)) { grid.CurrentCell = grid[j, i]; lblValidation.Text = "Please enter numeric."; return true; } else if (Convert.ToString(grid.Rows[i].Cells["quantity2"].Value.GetString()) == "0") { grid.CurrentCell = grid[j, i]; lblValidation.Text = "Can't fill be zero."; return true; } else { lblValidation.Text = ""; } } //Weight if (grid.Columns[j].Name == "weight2") { decimal tp; if (!decimal.TryParse(Convert.ToString(grid.Rows[i].Cells["weight2"].Value.GetString()), out tp)) { grid.CurrentCell = grid[j, i]; lblValidation.Text = "Please enter numeric."; return true; } else if (Convert.ToString(grid.Rows[i].Cells["weight2"].Value.GetString()) == "0") { grid.CurrentCell = grid[j, i]; lblValidation.Text = "Can't fill be zero."; return true; } else { lblValidation.Text = ""; } } //Place dose existing if (grid.Columns[j].Name == "place1") { if (string.IsNullOrEmpty(grid[j, i].Value.GetString())) { grid.CurrentCell = grid[j, i]; lblValidation.Text = "Please fill data on current focus."; return true; } WhseByRow = _repoWhse.GetByID(grid.Rows[i].Cells["place1"].Value.GetString()); if (WhseByRow == null) { grid.CurrentCell = grid[j, i]; lblValidation.Text = "This Place dosen't exist in the system."; return true; } else { lblValidation.Text = ""; } } } catch (NullReferenceException ex) { return false; } } } //if (Convert.ToDecimal(txtWeightBalnce.Text) != Convert.ToDecimal(txtRemainingWeight.Text)) //{ // error = true; // label5.Text = "Receipt weight must be equal Actual receipt weight!."; //} //else //{ // label5.Text = ""; //} return error; }
private void butDelete_Click(object sender, EventArgs e) { if (HeadContent.LookupID == 0) { MessageBox.Show("Please select line.", "Data not valid.", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } MappingLookupModel model = new MappingLookupModel(); model.TypeCode = "CUST"; model.LookupID = HeadContent.LookupID; model.SupplierCode = HeadContent.SupplierCode; model.SupCode = txtSource.Text.Trim(); model.UCCCode = txtCustID.Text.Trim(); var result = _repo.Delete(model); SetGrid(result); }
private void SetHeadContent(MappingLookupModel model) { txtSupplierName.Text = model.SupplierName; txtSource.Text = model.SupCode; }
private void SetHeadContent(MappingLookupModel model) { //txtStoreInPlanNum.DataBindings.Add("Text", model, "StoreInPlanNum", false, DataSourceUpdateMode.OnPropertyChanged); txtSupplierName.Text = model.SupplierName; txtSource.Text = model.SupCode; }