protected void Page_Load(object sender, EventArgs e) { System.Web.HttpCookie authCookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; if (authCookie == null) { return; } var encTicket = authCookie.Value; var ticket = FormsAuthentication.Decrypt(encTicket); if (ticket != null) { _userId = ticket.UserData; } if (Page.IsPostBack) { return; } ListarOrdenPaginadas(); var fesaDataSource = new FesaDataSourceDataContext(); OfficeList.DataSource = fesaDataSource.GET_ALL_OFFICE(); OfficeList.DataBind(); CostCenterList.DataSource = fesaDataSource.GET_ALL_COSTCENTER(); CostCenterList.DataBind(); }
public void AddNewDetailRow(bool checkLastRow) { var currentRowIndex = (SelectedMainRow.DetailsList.IndexOf(SelectedDetailRow)); if (checkLastRow) { var valiationCollection = new List <ValidationResult>(); var isvalid = Validator.TryValidateObject(SelectedDetailRow, new ValidationContext(SelectedDetailRow, null, null), valiationCollection, true); if (!isvalid) { return; } } if (AllowAdd != true) { MessageBox.Show(strings.AllowAddMsg); return; } var newrow = new TblCostCenterShopAreaModel { shoparea = SelectedMainRow.Iserial }; newrow.JournalAccountType = new GenericTable() { Iserial = CostCenterList.FirstOrDefault().TblCostCenterType ?? 0, Ename = "", Aname = "", Code = "", }; SelectedMainRow.DetailsList.Insert(currentRowIndex + 1, newrow); SelectedDetailRow = newrow; }
public ShopAreaViewModel() { if (!IsDesignTime) { GetItemPermissions(PermissionItemName.ShopArea.ToString()); Glclient = new GlServiceClient(); var costDimSetupTypeClient = new GlServiceClient(); costDimSetupTypeClient.GetGenericCompleted += (s, sv) => { BrandList = sv.Result; }; costDimSetupTypeClient.GetGenericAsync("TblItemDownLoadDef", "%%", "%%", "%%", "Iserial", "ASC", LoggedUserInfo.DatabasEname); Glclient.GetRetailChainSetupByCodeAsync("ShopAreaCostCenterType", LoggedUserInfo.DatabasEname); Glclient.GetRetailChainSetupByCodeCompleted += (s, sv) => { int costcentertype = Convert.ToInt32(sv.Result.sSetupValue); Glclient.GetTblCostCenterAsync(MainRowList.Count, PageSize, costcentertype, "it.Iserial", null, null, LoggedUserInfo.DatabasEname, LoggedUserInfo.Iserial, 0, 0); }; Glclient.GetTblCostCenterCompleted += (s, sv) => { CostCenterList = sv.Result; }; MainRowList = new ObservableCollection <TblshopareaModel>(); SelectedMainRow = new TblshopareaModel(); Glclient.GetshopareaCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TblshopareaModel(); newrow.InjectFrom(row); var storeTempRow = sv.StoreList.FirstOrDefault(w => w.code == row.shopcode); if (storeTempRow != null) { newrow.StorePerRow = new CRUDManagerService.StoreForAllCompany() { Code = storeTempRow.code, Aname = storeTempRow.aname, Ename = storeTempRow.ENAME, }; } newrow.BrandPerRow = new GenericTable(); var BrandTempRow = sv.BrandList.FirstOrDefault(w => w.Code == row.Brand); newrow.BrandPerRow = new GenericTable() { Code = BrandTempRow.Code, Aname = BrandTempRow.Aname, Ename = BrandTempRow.Ename, }; MainRowList.Add(newrow); } Loading = false; FullCount = sv.fullCount; if (MainRowList.Any() && (SelectedMainRow == null)) { SelectedMainRow = MainRowList.FirstOrDefault(); } if (FullCount == 0 && MainRowList.Count == 0) { AddNewMainRow(false); } if (Export) { Export = false; AllowExport = true; //ExportGrid.ExportExcel("Account"); } }; Glclient.UpdateOrInsertshopareaCompleted += (s, ev) => { if (ev.Error != null) { MessageBox.Show(ev.Error.Message); } try { MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result); } catch (Exception) { } Loading = false; }; Glclient.DeleteshopareaCompleted += (s, ev) => { if (ev.Error != null) { MessageBox.Show(ev.Error.Message); } var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result); if (oldrow != null) { MainRowList.Remove(oldrow); } if (!MainRowList.Any()) { AddNewMainRow(false); } }; Glclient.GetTblCostCenterShopAreaCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TblCostCenterShopAreaModel(); newrow.InjectFrom(row); var storeTempRow = CostCenterList.FirstOrDefault(w => w.Iserial == row.TblCostCenter); if (storeTempRow != null) { newrow.CostCenterPerRow = new TblCostCenter() { Code = storeTempRow.Code, Aname = storeTempRow.Aname, Ename = storeTempRow.Ename, TblCostCenterType = storeTempRow.TblCostCenterType }; } SelectedMainRow.DetailsList.Add(newrow); } Loading = false; DetailFullCount = sv.fullCount; if (SelectedMainRow.DetailsList.Any() && (SelectedDetailRow == null)) { SelectedDetailRow = SelectedMainRow.DetailsList.FirstOrDefault(); } if (DetailFullCount == 0 && SelectedMainRow.DetailsList.Count == 0) { AddNewDetailRow(false); } }; Glclient.UpdateOrInsertTblCostCenterShopAreasCompleted += (s, ev) => { if (ev.Error != null) { MessageBox.Show(ev.Error.Message); } try { SelectedMainRow.DetailsList.ElementAt(ev.outindex).InjectFrom(ev.Result); } catch (Exception) { } Loading = false; }; Glclient.DeleteTblCostCenterShopAreaCompleted += (s, ev) => { if (ev.Error != null) { MessageBox.Show(ev.Error.Message); } var oldrow = SelectedMainRow.DetailsList.FirstOrDefault(x => x.Iserial == ev.Result); if (oldrow != null) { SelectedMainRow.DetailsList.Remove(oldrow); } if (!MainRowList.Any()) { AddNewDetailRow(false); } }; GetMaindata(); } }