public void SearchFn(int AccountID) { EditFlag = true; AddErrorTxt.Text = ""; Sub_Account = new SubAccount(); Sub_Account_List = new List <SubAccount>(); int level = 4; Sub_Account = db.SubAccount.ToList().Where(s => s.ID == AccountID).FirstOrDefault(); // Sub_Account.GetSubAccount_ByID(AccountID).ElementAtOrDefault(0); level = (int)Sub_Account.Level; SubAccount Sub_Account1 = db.SubAccount.ToList().Where(s => s.ID == AccountID).FirstOrDefault(); // Sub_Account.GetSubAccount_ByID(AccountID).ElementAtOrDefault(0); if (Sub_Account1 != null) { AccountNoForSearchDrop.SelectedValue = Sub_Account1.ID.ToString(); } AccountIDTxt.Text = Sub_Account1.ID.ToString(); SubAccountManulID = int.Parse(AccountIDTxt.Text); AccountNameTxt.Text = Sub_Account1.name; DateTxt.Text = ExtendedMethod.ParseDateToString((DateTime)Sub_Account1.RegisterDate); AccountStateDrop.SelectedValue = Sub_Account1.BType; BalanceTxt.Text = Sub_Account1.ABalance.ToString(); Indx PersonalIndx = new Indx(); try { PersonalIndx = db.Indx.ToList().Where(i => i.Sub_ID == Int64.Parse(AccountIDTxt.Text)).FirstOrDefault();// PersonalIndx.GetIndx_BySubID(Int64.Parse(AccountIDTxt.Text)).FirstOrDefault(); if (PersonalIndx.ClientCategory != "") { ClientCategoryList.SelectedItem.Text = PersonalIndx.ClientCategory; } if (PersonalIndx.ClientType != "") { ClentTypelist.SelectedItem.Text = PersonalIndx.ClientType; } if (PersonalIndx.SalesUesrId.ToString() != "") { SalesUesrId.SelectedValue = PersonalIndx.SalesUesrId.ToString(); } ResponsiblePersonName.Text = PersonalIndx.ResponsiblePersonName; ResponsiblePersonPhone.Text = PersonalIndx.ResponsiblePersonPhone; AnotherResponsiblePersonPhone.Text = PersonalIndx.AnotherResponsiblePersonPhone; EmailTxt.Text = PersonalIndx.Email;; Addess.Text = PersonalIndx.Address; Sgl_TaxNO.Text = PersonalIndx.Sgl_TaxNO; CommercialDocument.Text = PersonalIndx.CommercialDocument; TaxDocument.Text = PersonalIndx.TaxDocument; PersonalIndx.Sub_ID = Int64.Parse(AccountIDTxt.Text); } catch (Exception ex) { } OldSubAccountManul = SubAccountManulID; }
public void SearchFn(int AccountID) { EditFlag = true; AddErrorTxt.Text = ""; Sub_Account = new SubAccount(); Sub_Account_List = new List <SubAccount>(); int level = 4; Sub_Account = db.SubAccount.ToList().Where(s => s.ID == AccountID).FirstOrDefault(); // Sub_Account.GetSubAccount_ByID(AccountID).ElementAtOrDefault(0); level = (int)Sub_Account.Level; SubAccount Sub_Account1 = db.SubAccount.ToList().Where(s => s.ID == AccountID).FirstOrDefault(); // Sub_Account.GetSubAccount_ByID(AccountID).ElementAtOrDefault(0); if (Sub_Account1 != null) { AccountNoForSearchDrop.SelectedValue = Sub_Account1.ID.ToString(); } AccountIDTxt.Text = Sub_Account1.ID.ToString(); SubAccountManulID = int.Parse(AccountIDTxt.Text); AccountNameTxt.Text = Sub_Account1.name; DateTxt.Text = ExtendedMethod.ParseDateToString((DateTime)Sub_Account1.RegisterDate); AccountStateDrop.SelectedValue = Sub_Account1.BType; BalanceTxt.Text = Sub_Account1.ABalance.ToString(); Indx PersonalIndx = new Indx(); try { PersonalIndx = db.Indx.ToList().Where(i => i.Sub_ID == Int64.Parse(AccountIDTxt.Text)).FirstOrDefault();// PersonalIndx.GetIndx_BySubID(Int64.Parse(AccountIDTxt.Text)).FirstOrDefault(); PersonalID.Text = PersonalIndx.PersonalID; MobileNoTxt.Text = PersonalIndx.MobileNo; EmailTxt.Text = PersonalIndx.Email; Sgl_TaxNO.Text = PersonalIndx.Sgl_TaxNO; TaxDocument.Text = PersonalIndx.TaxDocument; maamoriaTxt.Text = PersonalIndx.Maamria; Addess.Text = PersonalIndx.Address; } catch (Exception ex) { } OldSubAccountManul = SubAccountManulID; }
protected void SaveBtn_Click(object sender, EventArgs e) { Sub_Account = new SubAccount(); Sub_Account_List = new List <SubAccount>(); PersonalIndx = new Indx(); PersonalIndxList = new List <Indx>(); AccountIDTxt.Text = SubAccountManulID.ToString(); if (AccountNameTxt.Text != "") { string IndxFlag = CheckIndx(); if (IndxFlag == "") { Sub_Account.ID = int.Parse(AccountIDTxt.Text); Sub_Account.name = AccountNameTxt.Text; //Sub_Account.AccountID = Int64.Parse(OldSubAccountManul.ToString()); Sub_Account.MainAccount_id = 2103; Sub_Account.BType = AccountStateDrop.SelectedValue; Sub_Account.RegisterDate = DateTime.Parse(DateTxt.Text, CultureInfo.CreateSpecificCulture("ar-EG")); Sub_Account.ABalance = decimal.Parse(BalanceTxt.Text == "" ? "0" : BalanceTxt.Text); Sub_Account.Level = 4; //LoginedUser.ID Sub_Account.LoginID = ExtendedMethod.LoginedUser.Id; Sub_Account_List.Add(Sub_Account); PersonalIndx.Address = Addess.Text; PersonalIndx.Email = EmailTxt.Text; PersonalIndx.MobileNo = MobileNoTxt.Text; PersonalIndx.PersonalID = PersonalID.Text; PersonalIndx.Maamria = maamoriaTxt.Text; PersonalIndx.Sgl_TaxNO = Sgl_TaxNO.Text; PersonalIndx.Sub_ID = Int64.Parse(AccountIDTxt.Text); PersonalIndx.TaxDocument = TaxDocument.Text; PersonalIndxList.Add(PersonalIndx); if (EditFlag == true) { db.SubAccount.AddOrUpdate(Sub_Account); try { Int64 IndxID = db.Indx.ToList().Where(i => i.Sub_ID == int.Parse(AccountIDTxt.Text)).FirstOrDefault().ID;// PersonalIndx.GetIndx_BySubID(int.Parse(AccountIDTxt.Text)).FirstOrDefault().ID; PersonalIndx.ID = IndxID; // PersonalIndx.Operations("Edit", PersonalIndxList); db.Indx.AddOrUpdate(PersonalIndx); } catch (Exception ex) { db.Indx.Add(PersonalIndx); } } else { db.SubAccount.Add(Sub_Account); db.Indx.Add(PersonalIndx); try { db.SaveChanges(); } catch (Exception ex) { } } Initialize_Page(); AddErrorTxt.Text = "تم الحفظ بنجاح"; AddErrorTxt.ForeColor = System.Drawing.Color.Green; } else { AddErrorTxt.Text = IndxFlag; AddErrorTxt.ForeColor = System.Drawing.Color.Red; } } }
public void SearchFn(int AccountID) { EditFlag = true; AddErrorTxt.Text = ""; Main_Account = new MainAccount(); Main_Account_List = new List <MainAccount>(); Sub_Account = new SubAccount(); Sub_Account_List = new List <SubAccount>(); int level = int.Parse(AccountLevelDrop.SelectedValue); try { Main_Account = db.MainAccount.Where(main => main.ID == AccountID).FirstOrDefault(); level = Convert.ToInt32(Main_Account.Level); } catch (Exception ex) { Sub_Account = db.SubAccount.Where(sub => sub.ID == AccountID).FirstOrDefault(); level = Convert.ToInt32(Sub_Account.Level); } //int RootID = int.Parse(RootDrop.SelectedValue); if (level < 4)//Main Account { MainAccount Main_Account1 = db.MainAccount.Where(main => main.ID == AccountID).FirstOrDefault(); if (Main_Account1 != null) { AccountNoForSearchDrop.SelectedValue = Main_Account1.ID.ToString(); AccountLevelDrop.SelectedValue = Main_Account1.Level.ToString(); RootDrop.SelectedValue = Main_Account1.ID.ToString()[0].ToString(); AccountLevelDrop_SelectedIndexChanged(this, null); } if (level != 2) { UpAccountDrop.SelectedValue = Main_Account1.UpAccount.ToString(); } AccountIDTxt.Text = Main_Account1.ID.ToString(); subAccountID = int.Parse(AccountIDTxt.Text); AccountNameTxt.Text = Main_Account1.name; AccountStateRow.Visible = false; AccountBalanceRow.Visible = false; DateRow.Visible = false; } else//SubAccount { SubAccount Sub_Account1 = db.SubAccount.Where(sub => sub.ID == AccountID).FirstOrDefault(); if (Sub_Account1 != null) { AccountNoForSearchDrop.SelectedValue = Sub_Account1.ID.ToString(); AccountLevelDrop.SelectedValue = Sub_Account1.Level.ToString(); RootDrop.SelectedValue = Sub_Account1.ID.ToString()[0].ToString(); AccountLevelDrop_SelectedIndexChanged(this, null); } UpAccountDrop.SelectedValue = Sub_Account1.MainAccount_id.ToString(); AccountIDTxt.Text = Sub_Account1.ID.ToString(); subAccountID = int.Parse(AccountIDTxt.Text); AccountNameTxt.Text = Sub_Account1.name; DateTxt.Text = Sub_Account1.RegisterDate.ToString(); AccountStateDrop.SelectedValue = Sub_Account1.BType; BalanceTxt.Text = Sub_Account1.ABalance.ToString(); Indx PersonalIndx = new Indx(); try { var up = int.Parse(AccountIDTxt.Text); PersonalIndx = db.Indx.Where(index => index.Sub_ID == up).FirstOrDefault(); PersonalID.Text = PersonalIndx.PersonalID; MobileNoTxt.Text = PersonalIndx.MobileNo; EmailTxt.Text = PersonalIndx.Email; Sgl_TaxNO.Text = PersonalIndx.Sgl_TaxNO; TaxDocument.Text = PersonalIndx.TaxDocument; maamoriaTxt.Text = PersonalIndx.Maamria; Addess.Text = PersonalIndx.Address; } catch (Exception ex) { } if (Sub_Account1.MainAccount_id.ToString() == "1101" || Sub_Account1.MainAccount_id.ToString() == "2103") { IndxPart.Visible = true; } else { IndxPart.Visible = false; } AccountStateRow.Visible = true; AccountBalanceRow.Visible = true; DateRow.Visible = true; } OldSubAccount = subAccountID; }
protected void SaveBtn_Click(object sender, EventArgs e) { AccountIDTxt.Text = subAccountID.ToString(); Main_Account = new MainAccount(); Main_Account_List = new List <MainAccount>(); Sub_Account = new SubAccount(); Sub_Account_List = new List <SubAccount>(); PersonalIndx = new Indx(); PersonalIndxList = new List <Indx>(); long AccountID; //= int.Parse(AccountIDTxt.Text); if (AccountNameTxt.Text != "") { if (int.Parse(AccountLevelDrop.SelectedValue) < 4) { Main_Account.ID = int.Parse(AccountIDTxt.Text); AccountID = int.Parse(OldSubAccount.ToString()); Main_Account.name = AccountNameTxt.Text; if (int.Parse(AccountLevelDrop.SelectedValue) == 2) { Main_Account.UpAccount = int.Parse(RootDrop.SelectedValue); } else { Main_Account.UpAccount = int.Parse(UpAccountDrop.SelectedValue); } Main_Account.Level = int.Parse(AccountLevelDrop.SelectedValue); //LoginedUser.ID Main_Account.LoginID = ExtendedMethod.LoginedUser.Id; db.MainAccount.AddOrUpdate(Main_Account); db.SaveChanges(); Initialize_Page(); AddErrorTxt.Text = "تم الحفظ بنجاح"; } else { string IndxFlag = ""; if (UpAccountDrop.SelectedValue == "1101" || UpAccountDrop.SelectedValue == "2103") { IndxFlag = CheckIndx(); } if (IndxFlag == "") { Sub_Account.ID = int.Parse(AccountIDTxt.Text); Sub_Account.name = AccountNameTxt.Text; AccountID = int.Parse(OldSubAccount.ToString()); Sub_Account.MainAccount_id = int.Parse(UpAccountDrop.SelectedValue); Sub_Account.BType = AccountStateDrop.SelectedValue; Sub_Account.RegisterDate = DateTime.Parse(DateTxt.Text, CultureInfo.CreateSpecificCulture("ar-EG")); Sub_Account.ABalance = decimal.Parse(BalanceTxt.Text == "" ? "0" : BalanceTxt.Text); Sub_Account.Level = int.Parse(AccountLevelDrop.SelectedValue); //LoginedUser.ID Sub_Account.LoginID = ExtendedMethod.LoginedUser.Id; Sub_Account_List.Add(Sub_Account); PersonalIndx.Sub_ID = int.Parse(AccountIDTxt.Text); if (UpAccountDrop.SelectedValue == "1101" || UpAccountDrop.SelectedValue == "2103") { PersonalIndx.Address = Addess.Text; PersonalIndx.Email = EmailTxt.Text; PersonalIndx.MobileNo = MobileNoTxt.Text; PersonalIndx.PersonalID = PersonalID.Text; PersonalIndx.Maamria = maamoriaTxt.Text; PersonalIndx.Sgl_TaxNO = Sgl_TaxNO.Text; PersonalIndx.TaxDocument = TaxDocument.Text; PersonalIndx.LoginID = ExtendedMethod.LoginedUser.Id; } PersonalIndxList.Add(PersonalIndx); if (EditFlag == true) { db.SubAccount.AddOrUpdate(Sub_Account); db.SaveChanges(); try { var up = int.Parse(AccountIDTxt.Text); long IndxID = db.Indx.Where(index => index.Sub_ID == up).FirstOrDefault().ID; PersonalIndx.ID = IndxID; PersonalIndx.LoginID = ExtendedMethod.LoginedUser.Id; db.Indx.AddOrUpdate(PersonalIndx); db.SaveChanges(); Initialize_Page(); AddErrorTxt.Text = "تم الحفظ بنجاح"; AddErrorTxt.ForeColor = System.Drawing.Color.Green; } catch (Exception ex) { db.Indx.AddOrUpdate(PersonalIndx); db.SaveChanges(); Initialize_Page(); AddErrorTxt.Text = "تم الحفظ بنجاح"; AddErrorTxt.ForeColor = System.Drawing.Color.Green; } } else { db.SubAccount.AddOrUpdate(Sub_Account); db.SaveChanges(); db.Indx.AddOrUpdate(PersonalIndx); db.SaveChanges(); Initialize_Page(); AddErrorTxt.Text = "تم الحفظ بنجاح"; AddErrorTxt.ForeColor = System.Drawing.Color.Green; } } else { AddErrorTxt.Text = IndxFlag; AddErrorTxt.ForeColor = System.Drawing.Color.Red; } } } }
static void Main() { Indx index = new Indx(); Console.Write(index[2]); }