protected void CV_ServerValidate(object source, ServerValidateEventArgs args) { CustomValidator cv = (CustomValidator)source; switch (cv.ID) { case "cvCode": if (ThePriceListMgr.LoadPriceList(args.Value) != null) { ShowWarningMessage("MasterData.PriceList.Code.Exist", args.Value); args.IsValid = false; } break; case "cvParty": if (ThePartyMgr.LoadParty(args.Value) == null) { ShowWarningMessage("MasterData.Party.Code.NotExist", args.Value); args.IsValid = false; } break; default: break; } }
protected void ODS_PriceListDetail_Updating(object sender, ObjectDataSourceMethodEventArgs e) { string priceListCode = ((TextBox)(this.FV_PriceListDetail.FindControl("tbPriceList"))).Text.Trim(); string itemCode = ((TextBox)(this.FV_PriceListDetail.FindControl("tbItem"))).Text.Trim(); string currencyCode = ((Controls_TextBox)(this.FV_PriceListDetail.FindControl("tbCurrency"))).Text.Trim(); string uomCode = ((Controls_TextBox)(this.FV_PriceListDetail.FindControl("tbUom"))).Text.Trim(); string startDate = ((TextBox)(this.FV_PriceListDetail.FindControl("tbStartDate"))).Text.Trim(); string endDate = ((TextBox)(this.FV_PriceListDetail.FindControl("tbEndDate"))).Text.Trim(); priceListdetail = (PriceListDetail)e.InputParameters[0]; if (priceListdetail != null) { priceListdetail.PriceList = ThePriceListMgr.LoadPriceList(priceListCode); item = TheItemMgr.LoadItem(itemCode); priceListdetail.Item = item; priceListdetail.Currency = TheCurrencyMgr.LoadCurrency(currencyCode); //default uom if (uomCode == "") { priceListdetail.Uom = item.Uom; } else { priceListdetail.Uom = TheUomMgr.LoadUom(uomCode); } } }
protected void lbtnDelete_Click(object sender, EventArgs e) { string code = ((LinkButton)sender).CommandArgument; try { ThePriceListMgr.DeletePriceList(code); ShowSuccessMessage("MasterData.PriceList.Delete.Successfully", code); UpdateView(); } catch (Castle.Facilities.NHibernateIntegration.DataException ex) { ShowErrorMessage("MasterData.PriceList.Delete.Failed", code); } }
protected void CV_ServerValidate(object source, ServerValidateEventArgs args) { CustomValidator cv = (CustomValidator)source; switch (cv.ID) { case "cvUom": if (TheUomMgr.LoadUom(args.Value) == null) { ShowWarningMessage("MasterData.PriceList.UomInvalid", args.Value); args.IsValid = false; } break; case "cvItem": if (TheItemMgr.LoadItem(args.Value) == null) { ShowWarningMessage("MasterData.Item.Code.NotExist"); args.IsValid = false; } break; case "cvPriceList": if (ThePriceListMgr.LoadPriceList(args.Value) == null) { ShowWarningMessage("MasterData.PriceList.Code.NotExist"); args.IsValid = false; } break; case "cvUnitPrice": try { Convert.ToDecimal(args.Value); } catch (Exception) { ShowWarningMessage("MasterData.PriceListDetail.UnitPrice.Error"); args.IsValid = false; } break; case "cvStartDate": try { Convert.ToDateTime(args.Value); } catch (Exception) { ShowWarningMessage("Common.Date.Error"); args.IsValid = false; } break; case "cvEndDate": try { if (args.Value.Trim() != "") { DateTime startDate = Convert.ToDateTime(((TextBox)(this.FV_PriceListDetail.FindControl("tbStartDate"))).Text.Trim()); if (DateTime.Compare(startDate, Convert.ToDateTime(args.Value)) >= 0) { ShowErrorMessage("MasterData.PriceList.TimeCompare"); args.IsValid = false; } } } catch (Exception) { ShowWarningMessage("Common.Date.Error"); args.IsValid = false; } break; case "cvCurrency": if (args.Value.Trim() != "") { if (TheCurrencyMgr.LoadCurrency(args.Value) == null) { ShowWarningMessage("MasterData.Currency.Code.NotExist", args.Value); args.IsValid = false; } } break; default: break; } }