protected void edit_Command(object sender, CommandEventArgs e) { Cars temCar = new Cars(); int index = Convert.ToInt32(e.CommandArgument); if (SearchCarsList.Count > 0) { temCar = SearchCarsList[index]; } else { temCar = CarsList[index]; } try { CarsIdHid.Value = temCar.id.ToString(); CarNoTxt.Text = temCar.CarNo; LicenceNOTxt.Text = temCar.LicenceNO; LicenceDateTxt.Text = ExtendedMethod.ParseDateToString(DateTime.Parse(temCar.LicenceDate.ToString())); LicencePeriodTxt.Text = temCar.LicencePeriod.ToString(); AlertPeriodTxt.Text = temCar.AlertPeriod.ToString(); AddColorListhtml.SelectedValue = temCar.ColorId.ToString(); AddCityListhtml.SelectedValue = temCar.CityId.ToString(); AddCarTypeListhtml.SelectedValue = temCar.CarTypeId.ToString(); AddTrafDepListhtml.SelectedValue = temCar.TrafficDepID.ToString(); AddSupplierListhtml.SelectedValue = temCar.SubAccId.ToString(); } catch (Exception Exec) { } SearchCarsList = new List <Cars>(); UpdatePanel3.Update(); }
protected void edit_Command(object sender, CommandEventArgs e) { Driver temDriver = new Driver(); int index = Convert.ToInt32(e.CommandArgument); if (SearchDriverList.Count > 0) { temDriver = SearchDriverList[index]; } else { temDriver = DriverList[index]; } try { IdHid.Value = temDriver.Id.ToString(); NameTxt.Text = temDriver.Name; AddressTxt.Text = temDriver.Address; PhoneTxt.Text = temDriver.phone; licenseTxt.Text = temDriver.license; LicenceDateTxt.Text = ExtendedMethod.ParseDateToString(DateTime.Parse(temDriver.LicenceDate.ToString())); LicencePeriodTxt.Text = temDriver.LicencePeriod.ToString(); AlertPeriodTxt.Text = temDriver.AlertPeriod.ToString(); AddTrafDepListhtml.SelectedValue = temDriver.TrafficDepID.ToString(); } catch (Exception Exec) { } SearchDriverList = new List <Driver>(); UpdatePanel3.Update(); }
protected Driver DriverModel() { Driver driver = new Driver(); if (IdHid.Value != "0") { driver.Id = Convert.ToInt32(IdHid.Value); } if (NameTxt.Text != "") { driver.Name = NameTxt.Text; } if (AddressTxt.Text != "") { driver.Address = AddressTxt.Text; } if (PhoneTxt.Text != "") { driver.phone = PhoneTxt.Text; } if (licenseTxt.Text != "") { driver.license = licenseTxt.Text; } if (LicenceDateTxt.Text != "") { driver.LicenceDate = ExtendedMethod.FormatDate(LicenceDateTxt.Text); } if (LicencePeriodTxt.Text != "") { driver.LicencePeriod = int.Parse(LicencePeriodTxt.Text); } //Auto Calculate var date = DateTime.Parse(driver.LicenceDate.ToString()).Year + "-" + DateTime.Parse(driver.LicenceDate.ToString()).Month + "-" + DateTime.Parse(driver.LicenceDate.ToString()).Day; DateTime newyears = /*Convert.ToInt32(date[0])*/ DateTime.Parse(driver.LicenceDate.ToString()).AddYears(int.Parse(driver.LicencePeriod.ToString())); driver.LicenseEndDate = DateTime.Parse(newyears.Year + "-" + DateTime.Parse(driver.LicenceDate.ToString()).Month + "-" + DateTime.Parse(driver.LicenceDate.ToString()).Day, CultureInfo.CreateSpecificCulture("ar-EG")); if (AlertPeriodTxt.Text != "") { driver.AlertPeriod = Convert.ToInt32(AlertPeriodTxt.Text); } if (SelectedTrafDepId != "") { driver.TrafficDepID = Convert.ToInt32(SelectedTrafDepId); } driver.LoginID = ExtendedMethod.LoginedUser.Id; return(driver); }
protected void Page_Load(object sender, EventArgs e) { if (User.Identity.IsAuthenticated) { ExtendedMethod.LoginedUser = ExtendedMethod.GetUserData(User.Identity.Name); Response.Redirect("~/Views/Default.aspx"); } }
protected CarChangeRateOnDis CarChangeRateOnDisModel() { CarChangeRateOnDis carChangeRateOnDis = new CarChangeRateOnDis(); if (IdHid.Value != "0") { carChangeRateOnDis.Id = Convert.ToInt32(IdHid.Value); } if (Description.Text != "") { carChangeRateOnDis.Description = Description.Text; } if (SelectedCarId != "") { carChangeRateOnDis.CarId = Convert.ToInt32(SelectedCarId); } if (SelectedServiceId != "") { carChangeRateOnDis.ServiceId = Convert.ToInt32(SelectedServiceId); } //Before if (Before.Text != "") { carChangeRateOnDis.Before = Convert.ToDouble(Before.Text); } if (DateBefore.Text != "") { carChangeRateOnDis.DateBefore = ExtendedMethod.FormatDate(DateBefore.Text); } if (AtHourBefore.Text != "") { carChangeRateOnDis.AtHourBefore = AtHourBefore.Text; } //After if (After.Text != "") { carChangeRateOnDis.After = Convert.ToDouble(After.Text); } if (DateAfter.Text != "") { carChangeRateOnDis.DateAfter = ExtendedMethod.FormatDate(DateAfter.Text); } if (AtHourAfter.Text != "") { carChangeRateOnDis.AtHourAfter = AtHourAfter.Text; } carChangeRateOnDis.LoginID = ExtendedMethod.LoginedUser.Id; return(carChangeRateOnDis); }
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; }
protected void edit_Command(object sender, CommandEventArgs e) { EditFlage = true; //enable After Part Untill edit After.Enabled = true; DateAfter.Enabled = true; AtHourAfter.Enabled = true; //Disable Before Part Untill edit Before.Enabled = false; DateBefore.Enabled = false; AtHourBefore.Enabled = false; CarChangeRateOnDis temCarChangeRateOndis = new CarChangeRateOnDis(); int index = Convert.ToInt32(e.CommandArgument); if (SearchCarChangeRateOnDisList.Count > 0) { temCarChangeRateOndis = SearchCarChangeRateOnDisList[index]; } else { temCarChangeRateOndis = CarChangeRateOnDisList[index]; } try { IdHid.Value = temCarChangeRateOndis.Id.ToString(); Description.Text = temCarChangeRateOndis.Description; AddCarsListhtml.SelectedValue = temCarChangeRateOndis.CarId.ToString(); AddServicesListhtml.SelectedValue = temCarChangeRateOndis.ServiceId.ToString(); Before.Text = temCarChangeRateOndis.Before.ToString(); DateBefore.Text = ExtendedMethod.ParseDateToString(DateTime.Parse(temCarChangeRateOndis.DateBefore.ToString())); AtHourBefore.Text = temCarChangeRateOndis.AtHourBefore; After.Text = temCarChangeRateOndis.After.ToString(); DateAfter.Text = ExtendedMethod.ParseDateToString(DateTime.Parse(temCarChangeRateOndis.DateAfter.ToString())); AtHourAfter.Text = temCarChangeRateOndis.AtHourAfter; } catch (Exception Exec) { } SearchCarChangeRateOnDisList = new List <CarChangeRateOnDis>(); UpdatePanel3.Update(); }
protected PurchaseInvoice PurchaseInvoiceModel() { myPurchaseInvoice = new PurchaseInvoice(); if (InvoiceNo.Text != "") { myPurchaseInvoice.Id = InvoiceNo.Text; } // if (InvoiceDate.Text != "") { myPurchaseInvoice.InvoiceDate = ExtendedMethod.FormatDate(InvoiceDate.Text); } // if (Purchase.Checked) { myPurchaseInvoice.PurchaseType = Convert.ToBoolean(true); } else if (Discarded.Checked) { myPurchaseInvoice.PurchaseType = Convert.ToBoolean(false); } // if (vendorsListtxt.SelectedValue != "") { myPurchaseInvoice.SubAccountId = Convert.ToInt32(vendorsListtxt.SelectedValue); } // if (PaymentValue.Text != "") { myPurchaseInvoice.PaymentValue = Convert.ToDouble(PaymentValue.Text); } // if (Total.Text != "") { myPurchaseInvoice.Total = Convert.ToDouble(Total.Text); } // myPurchaseInvoice.PaymentMethod = PaymentMethod(myPurchaseInvoice.Total, myPurchaseInvoice.PaymentValue); // myPurchaseInvoice.UserID = 1; return(myPurchaseInvoice); }
protected SalesInvoice SalesInvoiceModel() { mySalesInvoice = new SalesInvoice(); if (InvoiceNo.Text != "") { mySalesInvoice.Id = InvoiceNo.Text; } // if (InvoiceDate.Text != "") { mySalesInvoice.InvoiceDate = ExtendedMethod.FormatDate(InvoiceDate.Text); } // if (Sale.Checked) { mySalesInvoice.PurchaseType = Convert.ToBoolean(true); } else if (Discarded.Checked) { mySalesInvoice.PurchaseType = Convert.ToBoolean(false); } // if (CarsListtxt.SelectedValue != "") { mySalesInvoice.CarId = Convert.ToInt32(CarsListtxt.SelectedValue); } // if (ServicesListtxt.SelectedValue != "") { mySalesInvoice.ServiceId = Convert.ToInt32(ServicesListtxt.SelectedValue); } // if (Total.Text != "") { mySalesInvoice.Total = Convert.ToDouble(Total.Text); } // mySalesInvoice.UserID = 1; return(mySalesInvoice); }
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 PurchaseInvoice SearchModel() { PurchaseInvoice purchaseInvoice = new PurchaseInvoice(); purchaseInvoice.SubAccountId = Convert.ToInt32(vendorsListtxt.SelectedValue); purchaseInvoice.Id = InvoiceNo.Text; purchaseInvoice.InvoiceDate = ExtendedMethod.FormatDate(InvoiceDate.Text); if (Purchase.Checked) { purchaseInvoice.PurchaseType = Convert.ToBoolean(true); } else if (Discarded.Checked) { purchaseInvoice.PurchaseType = Convert.ToBoolean(false); } return(purchaseInvoice); }
protected SalesInvoice SearchModel() { SalesInvoice salesInvoice = new SalesInvoice(); salesInvoice.CarId = Convert.ToInt32(CarsListtxt.SelectedValue); salesInvoice.Id = InvoiceNo.Text; salesInvoice.InvoiceDate = ExtendedMethod.FormatDate(InvoiceDate.Text); if (Sale.Checked) { salesInvoice.PurchaseType = Convert.ToBoolean(true); } else if (Discarded.Checked) { salesInvoice.PurchaseType = Convert.ToBoolean(false); } return(salesInvoice); }
public void ConcatenationLists(List <Entry> Account_Mony_Operations_List, List <AccountOperationsGrd> Account_Operations_List, float Account_Sum) { // int i = 0; // float sum = 0; foreach (var operation in Account_Mony_Operations_List) { string date = DateTime.Parse(operation.Date.ToString()).Year + "-" + DateTime.Parse(operation.Date.ToString()).Month + "-" + DateTime.Parse(operation.Date.ToString()).Day; // sum = Account_Sum > float.Parse(operation.Value.ToString()) ? Account_Sum - float.Parse(operation.Value.ToString()) : float.Parse(operation.Value.ToString()) - Account_Sum; // Account_Sum if (operation.status == "دائن")//مستلم العميل دائن { Account_Operations_List.Add(new AccountOperationsGrd() { OperationID = operation.ID, OperationDate = ExtendedMethod.FormatDate(date), Description = operation.description, CreditBalance = 0, IndebtBalance = 0, Credit_Movement = float.Parse(operation.value.ToString()), InDebt_Movement = 0, }); } else//مصروف العميل مدين { Account_Operations_List.Add(new AccountOperationsGrd() { OperationID = operation.ID, OperationDate = ExtendedMethod.FormatDate(date), Description = operation.description, CreditBalance = 0, IndebtBalance = 0, Credit_Movement = 0, InDebt_Movement = float.Parse(operation.value.ToString()), }); } } Account_Operations_List = Account_Operations_List.OrderBy(o => o.OperationDate).ToList(); }
protected void SaerchBtn_Click(object sender, EventArgs e) { RsltTxt.Text = ""; SaveBtn.Visible = true; khazna_Moved = new KhznaMoved(); entry = new Entry(); EntryGrd_List = new List <EntryGrd>(); //entry.maxid(); int maxid = (int)db.Entry.ToList().Max(o => o.EntryID) + 1; //entry.MoveID; Khazna_Moved_List = new List <KhznaMoved>(); //Khazna_Moved_List = khazna_Moved.GetAllKhznaMovedByKhaznaIDAndStateAndDate( // int.Parse(AccountDropID.SelectedValue), // 1, ToDateTxt.Text); Khazna_Moved_List = db.KhznaMoved.ToList().Where(o => o.AccountID == int.Parse(AccountDropID.SelectedValue) & o.state == true & o.Date <= ExtendedMethod.FormatDate(ToDateTxt.Text)).ToList(); int i = 0; foreach (var move in Khazna_Moved_List) { if (i == 0) { if (move.EntryState == false) { SaveBtn.Enabled = true; i++; } else { SaveBtn.Enabled = false; } } EntryGrd_List.Add(new EntryGrd() { EntryID = (int)move.EntryID, EntryState = (bool)move.EntryState, Description = move.Description, ID = move.ID, Value = float.Parse(move.Value.ToString()), SubID = int.Parse(move.AccountID.ToString()), }); } NewEntryTxtID.Text = maxid.ToString();//entry.MoveID.ToString(); EntryGrdV.DataSource = EntryGrd_List; EntryGrdV.DataBind(); }
protected void Set_initial() { //make custom ValidationGroup >>><<<< string vgId = Guid.NewGuid().ToString(); Description.ValidationGroup = vgId; //before Before.ValidationGroup = vgId; RequiredFieldValidator1.ValidationGroup = vgId; // DateBefore.ValidationGroup = vgId; RequiredFieldValidator2.ValidationGroup = vgId; // AtHourBefore.ValidationGroup = vgId; //After After.ValidationGroup = vgId; RequiredFieldValidator3.ValidationGroup = vgId; // DateAfter.ValidationGroup = vgId; RequiredFieldValidator4.ValidationGroup = vgId; // AtHourAfter.ValidationGroup = vgId; //Btn And summary ValidationSummary1.ValidationGroup = vgId; Save.ValidationGroup = vgId; //CarsList (For Adding will be forced to choose) CarsList = db.Cars.ToList(); AddCarsListhtml.DataSource = CarsList; AddCarsListhtml.DataTextField = "CarNo"; AddCarsListhtml.DataValueField = "Id"; AddCarsListhtml.DataBind(); // (For search will be optional to choose) List <Cars> TempCarsListlist = new List <Cars>(); TempCarsListlist.Add(new Cars { CarNo = "-- select CarNo --", id = 0 }); TempCarsListlist.AddRange(CarsList); CarsSearchListtxt.DataSource = TempCarsListlist; CarsSearchListtxt.DataTextField = "CarNo"; CarsSearchListtxt.DataValueField = "Id"; CarsSearchListtxt.DataBind(); //Services (For Adding will be forced to choose) ServicesList = db.Services.ToList(); BindDropDownList(ServicesList, AddServicesListhtml); // (For search will be optional to choose) List <Services> TempServiceslist = new List <Services>(); TempServiceslist.Add(new Services { Name = "-- select Services --", Id = 0 }); TempServiceslist.AddRange(ServicesList); BindDropDownList(TempServiceslist, ServicesSearchListtxt); Before.Text = "0"; DateBefore.Text = ExtendedMethod.GetDateToday(); // After.Text = "0"; DateAfter.Text = ExtendedMethod.GetDateToday(); //Disable After Part Untill edit EditFlage = false; After.Enabled = false; DateAfter.Enabled = false; AtHourAfter.Enabled = false; //enable Before Part Untill edit Before.Enabled = true; DateBefore.Enabled = true; AtHourBefore.Enabled = true; }
void searchFn(int ID) { EditFlag = true; Khzna_Moved = new KhznaMoved(); Bank_Moved = new BankMoved(); Sub_Account = new SubAccount(); OldEntry = new Entry(); if (MonyTypeDrop.SelectedIndex == 0) //نقدى { Khzna_Moved = db.KhznaMoved.Where(k => k.ID == ID & k.state == false).ToList().FirstOrDefault(); // Khzna_Moved.GetKhznaMoved_ByID(ID, 0).ElementAt(0); OperationID.Text = Khzna_Moved.ID.ToString(); Value.Text = String.Format("{0:0.00}", Khzna_Moved.Value); FromSubAccountsID.Items.Clear(); FromSubAccountsID.DataBind(); FromSubAccountsID.DataSource = db.SubAccount.ToList().Where(s => s.ID == int.Parse(Khzna_Moved.AccountID.ToString()));// Sub_Account.GetSubAccount_ByID(int.Parse(Khzna_Moved.AccountID.ToString())); FromSubAccountsID.DataValueField = "ID"; FromSubAccountsID.DataTextField = "name"; FromSubAccountsID.DataBind(); string khaznaNaname = ToKhaznaDrop.SelectedValue; //Sub_Account.GetSubAccount_ByID(int.Parse(Khzna_Moved.TreasuryID.ToString())).ElementAtOrDefault(0).name; ToKhaznaDrop.SelectedValue = khaznaNaname; DescTxt.Text = Khzna_Moved.Description; ReceivedDate.Text = ExtendedMethod.ParseDateToString((DateTime)Khzna_Moved.Date); if (Khzna_Moved.FinancialPostitionId != 0 && Khzna_Moved.FinancialPostitionType != "") { add_Edit_financialPosInfo((int)Khzna_Moved.FinancialPostitionId, Khzna_Moved.FinancialPostitionType); } DeleteMonyInBtn.Enabled = true; DeleteMonyInBtn.Enabled = true; OldKhznaID = int.Parse(ToKhaznaDrop.SelectedValue); OldEntry.Date = DateTime.Parse(ReceivedDate.Text, CultureInfo.CreateSpecificCulture("ar-EG")); OldEntry.description = DescTxt.Text; OldEntry.SubAccount_id = int.Parse(FromSubAccountsID.SelectedValue); OldValue = float.Parse(Value.Text); OldDescription = DescTxt.Text; } else//شيك { Bank_Moved = db.BankMoved.Where(b => b.ID == ID & b.state == false).ToList().FirstOrDefault();// Bank_Moved.GetBankMoving_ByID(ID, 0).ElementAt(0); if (Bank_Moved.FinancialPostitionId != 0 && Bank_Moved.FinancialPostitionType != "") { add_Edit_financialPosInfo((int)Bank_Moved.FinancialPostitionId, Bank_Moved.FinancialPostitionType); } OperationID.Text = Bank_Moved.ID.ToString(); Value.Text = String.Format("{0:0.00}", Bank_Moved.Value); //FromSubAccountsID.Items.Clear(); //FromSubAccountsID.DataBind(); //FromSubAccountsID.Items.Add(Sub_Account.GetSubAccount_ByID(int.Parse(Bank_Moved.AccountID.ToString())).ElementAt(0).name.ToString()); FromSubAccountsID.SelectedItem.Text = db.SubAccount.ToList().Where(s => s.ID == int.Parse(Bank_Moved.AccountID.ToString())).ToList().FirstOrDefault().name;// Sub_Account.GetSubAccount_ByID(int.Parse(Bank_Moved.AccountID.ToString())).ElementAt(0).name; DescTxt.Text = Bank_Moved.Description; ReceivedDate.Text = ExtendedMethod.ParseDateToString((DateTime)Khzna_Moved.Date); SarfDateTxt.Text = Bank_Moved.SarfDate.ToString(); DeleteMonyInBtn.Enabled = true; ChecqRow.Visible = true; //BankNameRow.Visible = true; ToKhaznaDrop.SelectedItem.Value = Bank_Moved.DocID.ToString(); ChequeNoTxt.Text = Bank_Moved.ChequeNo; //BankDropID.SelectedValue = Bank_Moved.BankName; DeleteMonyInBtn.Enabled = true; // OldDate = SarfDateTxt.Text; OldEntry.Date = DateTime.Parse(SarfDateTxt.Text, CultureInfo.CreateSpecificCulture("ar-EG")); OldCheq = ChequeNoTxt.Text; //OldBankName = BankDropID.SelectedValue; OldBankID = int.Parse(ToKhaznaDrop.SelectedValue); OldEntry.SubAccount_id = int.Parse(FromSubAccountsID.SelectedItem.Value); OldValue = float.Parse(Value.Text); OldDescription = DescTxt.Text; } }
public void Calc_Operation() { Account = new SubAccount(); Khazna_Moved_List = new List <Entry>(); Khazna_Moved = new Entry(); Khazna_Moved_List = db.Entry.ToList().Where(o => o.SubAccount_id == int.Parse(AccountDropID.SelectedValue) & o.Date <= ExtendedMethod.FormatDate(ToDateTxt.Text)).ToList(); //Khazna_Moved.GetEntry_ByAccountIDByDate(int.Parse(AccountDropID.SelectedValue), ToDateTxt.Text); SubAccount sub_Account = new SubAccount(); sub_Account = db.SubAccount.ToList().FirstOrDefault(o => o.ID == int.Parse(AccountDropID.SelectedValue)); // sub_Account.GetSubAccount_ByID(int.Parse(AccountDropID.SelectedValue)).ElementAtOrDefault(0); float Account_Sum = float.Parse(sub_Account.ABalance.ToString()); Account_Operations = new AccountOperationsGrd(); AccountOperations_List = new List <AccountOperationsGrd>(); Account_Mony_Operations_List = new List <Entry>(); Account_Operations_List = new List <AccountOperationsGrd>(); List <AccountOperationsGrd> FinalGrd = new List <AccountOperationsGrd>(); // DateTime.Parse(operation.Date.ToString()).Year //DateTime RD= DateTime.ParseExact(sub_Account.RegisterDate.ToString(), "yyyy-MM-dd", null); if (sub_Account.BType == "مدين") { FinalGrd.Add(new AccountOperationsGrd() { OperationID = 0, OperationDate = (DateTime)sub_Account.RegisterDate, CreditBalance = 0, Credit_Movement = 0, IndebtBalance = float.Parse(sub_Account.ABalance.ToString()), //InDebt_Movement = float.Parse(sub_Account.ABalance.ToString()), Description = "رصيد افتتاحى", }); } else { FinalGrd.Add(new AccountOperationsGrd() { OperationID = 0, OperationDate = (DateTime)sub_Account.RegisterDate, CreditBalance = 0, Credit_Movement = 0, IndebtBalance = -float.Parse(sub_Account.ABalance.ToString()), //InDebt_Movement = float.Parse(sub_Account.ABalance.ToString()), Description = "رصيد افتتاحى", }); } //كل العمليات مع الخزنة الخاصة بaccount foreach (var Khazna in Khazna_Moved_List) { Account_Mony_Operations_List.Add(new Entry { ID = (int)Khazna.EntryID, status = Khazna.status, value = Khazna.value, description = Khazna.description, SubAccount_id = Khazna.SubAccount_id, Date = Khazna.Date }); } Account_Mony_Operations_List.OrderByDescending(a => a.Date); //Concatination foreach (var operation in Account_Mony_Operations_List) { string date = DateTime.Parse(operation.Date.ToString()).Year + "-" + DateTime.Parse(operation.Date.ToString()).Month + "-" + DateTime.Parse(operation.Date.ToString()).Day; float sum = Account_Sum > float.Parse(operation.value.ToString()) ? Account_Sum - float.Parse(operation.value.ToString()) : float.Parse(operation.value.ToString()) - Account_Sum; // Account_Sum if (operation.status == "دائن")//مستلم { Account_Operations_List.Add(new AccountOperationsGrd() { OperationID = operation.ID, OperationDate = ExtendedMethod.FormatDate(date), Description = operation.description, CreditBalance = sum, IndebtBalance = 0, Credit_Movement = float.Parse(operation.value.ToString()), InDebt_Movement = 0, state = false, ABalance = float.Parse(sub_Account.ABalance.ToString()) }); } else//مصروف { Account_Operations_List.Add(new AccountOperationsGrd() { OperationID = operation.ID, OperationDate = ExtendedMethod.FormatDate(date), Description = operation.description, CreditBalance = 0, IndebtBalance = sum, Credit_Movement = 0, InDebt_Movement = float.Parse(operation.value.ToString()), state = true, ABalance = float.Parse(sub_Account.ABalance.ToString()) }); } } Account_Operations_List = Account_Operations_List.OrderBy(o => o.OperationDate).ToList(); string Todate = ReformateDateFromPicker(ToDateTxt.Text); //DateTime.Parse(ToDateTxt.Text).Year + "-" + DateTime.Parse(ToDateTxt.Text).Month + "-" + DateTime.Parse(ToDateTxt.Text).Day; FinalGrd.AddRange(Account_Operations_List.Where(o => o.OperationDate <= ExtendedMethod.FormatDate(Todate))); ////FinalGrd.AddRange(Account_Operations_List.Where(o => o.OperationDate >= DateTime.Parse(fromdate) & o.OperationDate <= DateTime.Parse(Todate))); //FinalGrd.Add(new AccountOperationsGrd() //{ // CreditBalance = FinalGrd.Sum(g => g.CreditBalance), // Credit_Movement = FinalGrd.Sum(g => g.Credit_Movement), // IndebtBalance = FinalGrd.Sum(g => g.IndebtBalance), // InDebt_Movement = FinalGrd.Sum(g => g.InDebt_Movement), // OperationID = 0, // Description = "", // OperationDate = FinalGrd.LastOrDefault().OperationDate //}); float lastBalance = FinalGrd.FirstOrDefault().state == true ? (FinalGrd.FirstOrDefault().CreditBalance) + (FinalGrd.Sum(c => c.Credit_Movement)) - (FinalGrd.Sum(c => c.InDebt_Movement)) : (FinalGrd.FirstOrDefault().IndebtBalance) + (FinalGrd.Sum(c => c.InDebt_Movement)) - (FinalGrd.Sum(c => c.Credit_Movement)); if (sub_Account.BType == "مدين") { Account_Operations = new AccountOperationsGrd() { CreditBalance = FinalGrd.Sum(g => g.CreditBalance), Credit_Movement = FinalGrd.Sum(g => g.Credit_Movement), IndebtBalance = FinalGrd.Sum(g => g.IndebtBalance), InDebt_Movement = FinalGrd.Sum(g => g.InDebt_Movement), OperationID = 0, Description = AccountDropID.SelectedItem.Text, OperationDate = FinalGrd.LastOrDefault().OperationDate, ABalance = float.Parse(sub_Account.ABalance.ToString()), LastBalance = lastBalance }; } else { Account_Operations = new AccountOperationsGrd() { CreditBalance = FinalGrd.Sum(g => g.CreditBalance), Credit_Movement = FinalGrd.Sum(g => g.Credit_Movement), IndebtBalance = FinalGrd.Sum(g => g.IndebtBalance), InDebt_Movement = FinalGrd.Sum(g => g.InDebt_Movement), OperationID = 0, Description = AccountDropID.SelectedItem.Text, OperationDate = FinalGrd.LastOrDefault().OperationDate, ABalance = -float.Parse(sub_Account.ABalance.ToString()), LastBalance = lastBalance }; } FinalGrd.Clear(); FinalGrd.Add(Account_Operations); FinalGrd1.Add(Account_Operations); AccountGrd.DataSource = FinalGrd1; //Account_Operations_List.Where(o=>o.OperationDate >= DateTime.Parse(FromDateTxt.Text) & o.OperationDate <= DateTime.Parse(ToDateTxt.Text)); AccountGrd.DataBind(); }
protected void SaerchBtn_Click(object sender, EventArgs e) { FromDateTxt.Text = ReformateDateFromPicker(FromDateTxt.Text); FalseCounter = 0; TaxFlag = false; OldKeadID = 0; entry = new Entry(); Entry_List = new List <Entry>(); Result_lst.Clear(); LSales = db.PurchaseInvoice.ToList().Where(o => o.InvoiceDate <= ExtendedMethod.FormatDate(FromDateTxt.Text) & o.PurchaseType == bool.Parse(BillTypeDrop.SelectedValue) ).ToList(); // Sale.GetAllPurchaseInvoiceInDate(DateTime.Parse(FromDateTxt.Text, // CultureInfo.CreateSpecificCulture("ar-EG")).ToString(), // bool.Parse(BillTypeDrop.SelectedValue));//Sale.GetAllPurchaseInvoice(FromDateTxt.Text, FromDateTxt .Text,BillTypeDrop.SelectedValue); foreach (var tt in LSales) { if (tt.KeadNo == 0) { FalseCounter++; } if (tt.PurchaseType == true) { if (tt.KeadNo != 0) { TaxFlag = true; OldKeadID = (int)tt.KeadNo; entry = db.Entry.FirstOrDefault(o => o.EntryID == int.Parse(OldKeadID.ToString())); //entry = entry.GetAllEntryByID(int.Parse(OldKeadID.ToString())).FirstOrDefault(); Entry_List.Add(entry); db.Entry.RemoveRange(Entry_List); // entry.Operations("Delete", Entry_List); db.SaveChanges(); } Result_lst.Add(new SalesResults { moveID = tt.Id, SValue = decimal.Parse(tt.Total.ToString()), KeadNo = (int)tt.KeadNo, subAccountID = int.Parse(tt.SubAccountId.ToString()) }); } else { if (tt.KeadNo != 0) { TaxFlag = true; OldKeadID = (int)tt.KeadNo; entry = db.Entry.FirstOrDefault(o => o.EntryID == int.Parse(OldKeadID.ToString()));// entry.GetAllEntryByID(int.Parse(OldKeadID.ToString())).FirstOrDefault(); Entry_List.Add(entry); //entry.Operations("Delete", Entry_List); db.Entry.RemoveRange(Entry_List); db.SaveChanges(); } // SNet = tt.Value_LE+tt.Tax_Added-tt.CommercialTax, SValue =tt.Value_LE Result_lst.Add(new SalesResults { moveID = tt.Id, SValue = (decimal)tt.Total, KeadNo = (int)tt.KeadNo, subAccountID = int.Parse(tt.SubAccountId.ToString()) }); } } AccountGrd.DataSource = Result_lst; AccountGrd.DataBind(); if (Result_lst.Count > 0) { AccountGrd.FooterRow.Cells[0].Text = "اجماليات"; AccountGrd.FooterRow.Cells[1].Text = Result_lst.Sum(c => c.SValue).ToString("#.00"); } else { ClientScript.RegisterStartupScript(this.GetType(), "تنبيه", "alert('لا يوجد نتائج');", true); } }
public void Calc_Operation() { attemptValue = 0; Account = new SubAccount(); Khazna_Moved_List = new List <Entry>(); Khazna_Moved = new Entry(); Khazna_Moved_List = db.Entry.ToList().Where(o => o.SubAccount_id == int.Parse(AccountDropID.SelectedValue) & ( o.Date >= ExtendedMethod.FormatDate(FromDateTxt.Text) & o.Date <= ExtendedMethod.FormatDate(ToDateTxt.Text))).ToList();// Khazna_Moved.GetEntry_ByAccountIDByDate( // int.Parse(AccountDropID.SelectedValue), FromDateTxt.Text, ToDateTxt.Text); SubAccount sub_Account = new SubAccount(); sub_Account = db.SubAccount.ToList().FirstOrDefault(o => o.ID == int.Parse(AccountDropID.SelectedValue)); // sub_Account.GetSubAccount_ByID(int.Parse(AccountDropID.SelectedValue)).ElementAtOrDefault(0); float Account_Sum = float.Parse(sub_Account.ABalance.ToString()); Account_Operations = new AccountOperationsGrd(); AccountOperations_List = new List <AccountOperationsGrd>(); Account_Mony_Operations_List = new List <Entry>(); Account_Operations_List = new List <AccountOperationsGrd>(); List <AccountOperationsGrd> FinalGrd = new List <AccountOperationsGrd>(); List <AccountOperationsGrd> LastGrd = new List <AccountOperationsGrd>(); // DateTime.Parse(operation.Date.ToString()).Year //DateTime RD= DateTime.ParseExact(sub_Account.RegisterDate.ToString(), "yyyy-MM-dd", null); if (sub_Account.BType == "دائن") { FinalGrd.Add(new AccountOperationsGrd() { OperationID = 0, OperationDate = (DateTime)sub_Account.RegisterDate, CreditBalance = float.Parse(sub_Account.ABalance.ToString()), Credit_Movement = 0, IndebtBalance = 0, InDebt_Movement = 0, Description = "رصيد افتتاحى", State = sub_Account.BType }); } else { FinalGrd.Add(new AccountOperationsGrd() { OperationID = 0, OperationDate = (DateTime)sub_Account.RegisterDate, CreditBalance = 0, Credit_Movement = 0, IndebtBalance = float.Parse(sub_Account.ABalance.ToString()), InDebt_Movement = 0, Description = "رصيد افتتاحى", State = sub_Account.BType }); } // LastGrd.Add(FinalGrd[0]); //كل العمليات مع الخزنة الخاصة بaccount foreach (var Khazna in Khazna_Moved_List) { Account_Mony_Operations_List.Add(new Entry { ID = (int)Khazna.EntryID, status = Khazna.status, value = Khazna.value, description = Khazna.description, SubAccount_id = Khazna.SubAccount_id, Date = Khazna.Date }); } // Account_Mony_Operations_List.OrderBy(a => a.Date); //Concatination////////////////////////////////////////////////////////////////////////////////////////////////////////// ConcatenationLists(Account_Mony_Operations_List, Account_Operations_List, Account_Sum); //الشغل على Account_Operations_List int i = 1; Account_Operations_List = Account_Operations_List.OrderBy(o => o.OperationDate).ToList(); attemptValue = FinalGrd[0].State == "دائن" ? FinalGrd[0].CreditBalance : FinalGrd[0].IndebtBalance; string CurrentState = ""; foreach (var operation in Account_Operations_List) { //CurrentState = FinalGrd[i - 1].State == "مدين" ? Math.Sign(attemptValue + operation.InDebt_Movement - operation.Credit_Movement) >= 0 ? "مدين" : "دائن" : // Math.Sign(attemptValue + operation.Credit_Movement- operation.InDebt_Movement) >= 0 ? "دائن" : "مدين"; if (FinalGrd[i - 1].State == "مدين") { if (operation.InDebt_Movement > 0) { attemptValue = Math.Abs(attemptValue + operation.InDebt_Movement - operation.Credit_Movement); if (attemptValue > 0) { CurrentState = "مدين"; } else { CurrentState = "دائن"; } } else { attemptValue = (attemptValue - operation.Credit_Movement + operation.InDebt_Movement); if (attemptValue > 0) { CurrentState = "مدين"; } else { CurrentState = "دائن"; attemptValue = -attemptValue; } } } else { if (operation.Credit_Movement > 0) { attemptValue = Math.Abs(attemptValue + operation.Credit_Movement - operation.InDebt_Movement); if (attemptValue > 0) { CurrentState = "دائن"; } else { CurrentState = "مدين"; } } else { attemptValue = (attemptValue - operation.InDebt_Movement + operation.Credit_Movement); if (attemptValue > 0) { CurrentState = "دائن"; } else { CurrentState = "مدين"; attemptValue = -attemptValue; } } } if (CurrentState == "دائن") { FinalGrd.Add(new AccountOperationsGrd() { CreditBalance = attemptValue, Credit_Movement = operation.Credit_Movement, IndebtBalance = operation.IndebtBalance, InDebt_Movement = operation.InDebt_Movement, Description = operation.Description, OperationDate = operation.OperationDate, OperationID = operation.OperationID, State = "دائن" }); } else { //if (operation.InDebt_Movement > 0) //{ // attemptValue = Math.Abs(attemptValue + operation.InDebt_Movement - operation.Credit_Movement); //} //else //{ // attemptValue = Math.Abs(attemptValue + operation.Credit_Movement - operation.InDebt_Movement); //} FinalGrd.Add(new AccountOperationsGrd() { CreditBalance = operation.CreditBalance, Credit_Movement = operation.Credit_Movement, IndebtBalance = attemptValue,// operation.IndebtBalance, InDebt_Movement = operation.InDebt_Movement, Description = operation.Description, OperationDate = operation.OperationDate, OperationID = operation.OperationID, State = "مدين" }); } i++; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Account_Operations_List = Account_Operations_List.OrderBy(o => o.OperationDate).ToList(); string fromdate = ReformateDateFromPicker(FromDateTxt.Text); //DateTime.Parse(FromDateTxt.Text).Year + "-" + DateTime.Parse(FromDateTxt.Text).Month + "-" + DateTime.Parse(FromDateTxt.Text).Day; string Todate = ReformateDateFromPicker(ToDateTxt.Text); //DateTime.Parse(ToDateTxt.Text).Year + "-" + DateTime.Parse(ToDateTxt.Text).Month + "-" + DateTime.Parse(ToDateTxt.Text).Day; LastGrd.Add(FinalGrd.Where(o => o.OperationDate < ExtendedMethod.FormatDate(fromdate)).LastOrDefault()); if (LastGrd.Last() == null) { LastGrd.Remove(LastGrd.Last()); } LastGrd.AddRange(FinalGrd.Where(o => o.OperationDate >= ExtendedMethod.FormatDate(fromdate) & o.OperationDate <= ExtendedMethod.FormatDate(Todate))); AccountGrd.DataSource = LastGrd;// FinalGrd.Where(o => o.OperationDate < DateTime.Parse(fromdate)).LastOrDefault() && o.OperationDate >= DateTime.Parse(fromdate) & o.OperationDate <= DateTime.Parse(Todate) ); //Account_Operations_List.Where(o=>o.OperationDate >= DateTime.Parse(FromDateTxt.Text) & o.OperationDate <= DateTime.Parse(ToDateTxt.Text)); AccountGrd.DataBind(); }
protected TransportCommand TransportCommandModel() { TransportCommand TransCmd = new TransportCommand(); try { //DateTime CDate = DateTime.ParseExact(TransCmdDate.Text, // "dd/MM/yyyy", // CultureInfo.CreateSpecificCulture("ar-EG")); if (TransCmdTxt.Text != "") { TransCmd.Id = Convert.ToInt32(TransCmdTxt.Text); } if (TransCmdDate.Text != "") { TransCmd.TransportCommandTime = DateTime.Parse(TransCmdDate.Text, CultureInfo.CreateSpecificCulture("ar-EG")); } if (SelectedSubAccClientId != "") { TransCmd.SubAccClientId = Convert.ToInt32(SelectedSubAccClientId); } }catch (Exception ex) { } if (SelectedSubAccViendorId != "") { TransCmd.SubAccVendorId = Convert.ToInt32(SelectedSubAccViendorId); } if (SelectedCarsId != "") { TransCmd.CarId = Convert.ToInt32(SelectedCarsId); } if (SelectedProductId != "") { TransCmd.ProductId = SelectedProductId; } if (SelectedFromRegionId != "") { TransCmd.FromRegionId = Convert.ToInt32(SelectedFromRegionId); } if (SelectedToRegionId != "") { TransCmd.ToRegionId = Convert.ToInt32(SelectedToRegionId); } if (TransportPrice.Text != "") { TransCmd.TransportPrice = Convert.ToDouble(TransportPrice.Text); } if (Quantity.Text != "") { TransCmd.Quantity = Convert.ToDouble(Quantity.Text); } if (SelectedTransportTypeId != "") { TransCmd.TransportType = SelectedTransportTypeId; } if (TotalTransportPrice.Text != "") { TransCmd.TotalTransportPrice = Convert.ToDouble(TotalTransportPrice.Text); } if (SelectedPaymentWayId != "") { TransCmd.PaymentWay = SelectedPaymentWayId; } if (AtHour.Text != "") { TransCmd.TimeOfShipping = AtHour.Text; } TransCmd.LoginID = ExtendedMethod.GetUserData(User.Identity.Name).Id; return(TransCmd); }
public void Calc_Operation() { attemptValue = 0; Account = new SubAccount(); Khazna_Moved_List = new List <KhznaMoved>(); Bank_Moved_List = new List <BankMoved>(); Purchase_Invoice_List = new List <PurchaseInvoice>(); Khazna_Moved = new KhznaMoved(); Bank_Moved = new BankMoved(); Purchase_Invoice = new PurchaseInvoice(); // Khazna_Moved_List = Khazna_Moved.GetKhznaMoved_ByAccountIDByDate(int.Parse(AccountDropID.SelectedValue),FromDateTxt.Text,ToDateTxt.Text); // Bank_Moved_List = Bank_Moved.BankMoved_Between_Date_ForAccount(FromDateTxt.Text,ToDateTxt.Text, int.Parse(AccountDropID.SelectedValue)); Khazna_Moved_List = db.KhznaMoved.ToList().Where(o => o.AccountID == int.Parse(AccountDropID.SelectedValue)).ToList(); // Khazna_Moved_List = Khazna_Moved.GetKhznaMoved_ByAccountID(int.Parse(AccountDropID.SelectedValue)); Bank_Moved_List = db.BankMoved.ToList().Where(o => o.AccountID == int.Parse(AccountDropID.SelectedValue)).ToList(); Purchase_Invoice_List = db.PurchaseInvoice.ToList().Where(p => p.SubAccountId == int.Parse(AccountDropID.SelectedValue)).ToList(); //Purchase_Invoice.GetPurchaseInvoiceBySubID(int.Parse(AccountDropID.SelectedValue)); SubAccount sub_Account = new SubAccount(); sub_Account = db.SubAccount.ToList().FirstOrDefault(s => s.ID == int.Parse(AccountDropID.SelectedValue));// sub_Account.GetSubAccount_ByID(int.Parse(AccountDropID.SelectedValue)).ElementAtOrDefault(0); float Account_Sum = float.Parse(sub_Account.ABalance.ToString()); Account_Operations = new AccountOperationsGrd(); AccountOperations_List = new List <AccountOperationsGrd>(); Account_Mony_Operations_List = new List <KhznaMoved>(); Account_Operations_List = new List <AccountOperationsGrd>(); List <AccountOperationsGrd> FinalGrd = new List <AccountOperationsGrd>(); List <AccountOperationsGrd> LastGrd = new List <AccountOperationsGrd>(); // DateTime.Parse(operation.Date.ToString()).Year //DateTime RD= DateTime.ParseExact(sub_Account.RegisterDate.ToString(), "yyyy-MM-dd", null); if (sub_Account.BType == "دائن") { FinalGrd.Add(new AccountOperationsGrd() { OperationID = 0, OperationDate = (DateTime)sub_Account.RegisterDate, CreditBalance = float.Parse(sub_Account.ABalance.ToString()), Credit_Movement = 0, IndebtBalance = 0, InDebt_Movement = 0, Description = "رصيد افتتاحى", State = sub_Account.BType }); } else { FinalGrd.Add(new AccountOperationsGrd() { OperationID = 0, OperationDate = (DateTime)sub_Account.RegisterDate, CreditBalance = 0, Credit_Movement = 0, IndebtBalance = float.Parse(sub_Account.ABalance.ToString()), InDebt_Movement = 0, Description = "رصيد افتتاحى", State = sub_Account.BType }); } // LastGrd.Add(FinalGrd[0]); //كل العمليات مع الخزنة الخاصة بaccount foreach (var Khazna in Khazna_Moved_List) { Account_Mony_Operations_List.Add(new KhznaMoved { ID = Khazna.ID, state = Khazna.state == true ? false : true, Value = Khazna.Value, Description = Khazna.Description, AccountID = Khazna.AccountID, Date = Khazna.Date }); } //كل العمليات الواقعة على التعاملات البنكية foreach (var bank in Bank_Moved_List) { Account_Mony_Operations_List.Add(new KhznaMoved { ID = bank.ID, state = bank.state == true ? false : true, Value = bank.Value, Description = bank.Description, AccountID = bank.AccountID, Date = bank.Date }); } //فواتير الشراء foreach (var Pur in Purchase_Invoice_List) { Account_Mony_Operations_List.Add(new KhznaMoved { ID = int.Parse(Pur.Id), state = (bool)Pur.PurchaseType, Value = decimal.Parse(Pur.Total.ToString()), Description = Pur.PurchaseType == true?"شراء":"مرتجع شراء", AccountID = Pur.SubAccountId, Date = DateTime.Parse(Pur.InvoiceDate.ToString(), CultureInfo.CreateSpecificCulture("ar-EG")) }); } List <TransportCommand> TransportComandList = new List <TransportCommand>(); TransportComandList = db.TransportCommand.ToList(); //اوامر النقل foreach (var Pur in TransportComandList) { Account_Mony_Operations_List.Add(new KhznaMoved { ID = Pur.Id, state = true, Value = decimal.Parse(Pur.TotalTransportPrice.ToString()), Description = "امر نقل", AccountID = Pur.SubAccVendorId, Date = ExtendedMethod.FormatDate(ExtendedMethod.ParseDateToString(DateTime.Parse(Pur.TransportCommandTime.ToString()))) }); } // Account_Mony_Operations_List.OrderBy(a => a.Date); //Concatination////////////////////////////////////////////////////////////////////////////////////////////////////////// ConcatenationLists(Account_Mony_Operations_List, Account_Operations_List, Account_Sum); //الشغل على Account_Operations_List int i = 1; Account_Operations_List = Account_Operations_List.OrderBy(o => o.OperationDate).ToList(); attemptValue = FinalGrd[0].State == "دائن" ? FinalGrd[0].CreditBalance : FinalGrd[0].IndebtBalance; string CurrentState = ""; foreach (var operation in Account_Operations_List) { //CurrentState = FinalGrd[i - 1].State == "مدين" ? Math.Sign(attemptValue + operation.InDebt_Movement - operation.Credit_Movement) >= 0 ? "مدين" : "دائن" : // Math.Sign(attemptValue + operation.Credit_Movement- operation.InDebt_Movement) >= 0 ? "دائن" : "مدين"; if (FinalGrd[i - 1].State == "مدين") { if (operation.InDebt_Movement > 0) { attemptValue = Math.Abs(attemptValue + operation.InDebt_Movement - operation.Credit_Movement); if (attemptValue > 0) { CurrentState = "مدين"; } else { CurrentState = "دائن"; } } else { attemptValue = (attemptValue - operation.Credit_Movement + operation.InDebt_Movement); if (attemptValue > 0) { CurrentState = "مدين"; } else { CurrentState = "دائن"; attemptValue = -attemptValue; } } } else { if (operation.Credit_Movement > 0) { attemptValue = Math.Abs(attemptValue + operation.Credit_Movement - operation.InDebt_Movement); if (attemptValue > 0) { CurrentState = "دائن"; } else { CurrentState = "مدين"; } } else { attemptValue = (attemptValue - operation.InDebt_Movement + operation.Credit_Movement); if (attemptValue > 0) { CurrentState = "دائن"; } else { CurrentState = "مدين"; attemptValue = -attemptValue; } } } if (CurrentState == "دائن") { FinalGrd.Add(new AccountOperationsGrd() { CreditBalance = attemptValue, Credit_Movement = operation.Credit_Movement, IndebtBalance = operation.IndebtBalance, InDebt_Movement = operation.InDebt_Movement, Description = operation.Description, OperationDate = operation.OperationDate, OperationID = operation.OperationID, State = "دائن" }); } else { //if (operation.InDebt_Movement > 0) //{ // attemptValue = Math.Abs(attemptValue + operation.InDebt_Movement - operation.Credit_Movement); //} //else //{ // attemptValue = Math.Abs(attemptValue + operation.Credit_Movement - operation.InDebt_Movement); //} FinalGrd.Add(new AccountOperationsGrd() { CreditBalance = operation.CreditBalance, Credit_Movement = operation.Credit_Movement, IndebtBalance = attemptValue,// operation.IndebtBalance, InDebt_Movement = operation.InDebt_Movement, Description = operation.Description, OperationDate = operation.OperationDate, OperationID = operation.OperationID, State = "مدين" }); } i++; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string fromdate = ReformateDateFromPicker(FromDateTxt.Text); // DateTime.Parse(FromDateTxt.Text).Year + "-" + DateTime.Parse(FromDateTxt.Text).Month + "-" + DateTime.Parse(FromDateTxt.Text).Day; string Todate = ReformateDateFromPicker(ToDateTxt.Text); //DateTime.Parse(ToDateTxt.Text).Year + "-" + DateTime.Parse(ToDateTxt.Text).Month + "-" + DateTime.Parse(ToDateTxt.Text).Day; var mydate = DateTime.Parse(fromdate, CultureInfo.CreateSpecificCulture("ar-EG")); var mydateTo = DateTime.Parse(Todate, CultureInfo.CreateSpecificCulture("ar-EG")); LastGrd.Add(FinalGrd.Where(o => o.OperationDate < mydate).LastOrDefault()); if (LastGrd.Last() == null) { LastGrd.Remove(LastGrd.Last()); } LastGrd.AddRange(FinalGrd.Where(o => o.OperationDate >= mydate & o.OperationDate <= mydateTo)); AccountGrd.DataSource = LastGrd;// FinalGrd.Where(o => o.OperationDate < DateTime.Parse(fromdate)).LastOrDefault() && o.OperationDate >= DateTime.Parse(fromdate) & o.OperationDate <= DateTime.Parse(Todate) ); //Account_Operations_List.Where(o=>o.OperationDate >= DateTime.Parse(FromDateTxt.Text) & o.OperationDate <= DateTime.Parse(ToDateTxt.Text)); AccountGrd.DataBind(); GridView1.DataSource = LastGrd; GridView1.DataBind(); Textbox1.Text = FromDateTxt.Text; Textbox2.Text = ToDateTxt.Text; Dropdownlist1.Text = AccountDropID.SelectedItem.Text; }