protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["EmployeeID"] != null && Request.QueryString["EmployeeID"].ToString() != "") { // This is for Showing Full Invoice long EmployeeID = Convert.ToInt32(Request.QueryString["EmployeeID"].ToString()); //long EmployeeDetailID = 0; PCSN.InvoiceSystem.BusinessLogicLayer.Employee Employee = new PCSN.InvoiceSystem.BusinessLogicLayer.Employee(); lblMainTitle.Text = "Employee Details"; dtEmployeeEdit = Employee.GetEmployeeByID(EmployeeID); if (dtEmployeeEdit.Rows.Count > 0) { lblDate.Text = DateTime.Now.ToShortDateString(); lblEmployeeID.Text = dtEmployeeEdit.Rows[0]["ID"].ToString(); lblDateOfJoin.Text = dtEmployeeEdit.Rows[0]["DateOfJoin"].ToString(); lblName.Text = dtEmployeeEdit.Rows[0]["Name"].ToString(); lblFName.Text = dtEmployeeEdit.Rows[0]["FatherName"].ToString(); lblDesignation.Text = dtEmployeeEdit.Rows[0]["Designation"].ToString(); lblNIC.Text = dtEmployeeEdit.Rows[0]["NIC"].ToString(); lblPhone.Text = dtEmployeeEdit.Rows[0]["Phone"].ToString(); LblMobile.Text = dtEmployeeEdit.Rows[0]["Mobile"].ToString(); lblEmail.Text = dtEmployeeEdit.Rows[0]["Email"].ToString(); lblAddress.Text = dtEmployeeEdit.Rows[0]["Address"].ToString(); lblCity.Text = dtEmployeeEdit.Rows[0]["City"].ToString(); lblCountry.Text = dtEmployeeEdit.Rows[0]["Country"].ToString(); lblReference.Text = dtEmployeeEdit.Rows[0]["Reference"].ToString(); lblDescription.Text = dtEmployeeEdit.Rows[0]["Description"].ToString(); lblStartingSalary.Text = dtEmployeeEdit.Rows[0]["StartingSalary"].ToString(); PCSN.InvoiceSystem.BusinessLogicLayer.OurCompany ourCompany = new PCSN.InvoiceSystem.BusinessLogicLayer.OurCompany(); DataTable dtOurCompany = new DataTable(); dtOurCompany = ourCompany.GetOurCompanyByID(Convert.ToInt32("1")); if (dtOurCompany.Rows.Count > 0) { //txtOurCompanyID.Text = dtOurCompany.Rows[0]["ID"].ToString(); lblCompanyName.Text = dtOurCompany.Rows[0]["CompanyName"].ToString() + Environment.NewLine; lblCompanyAddress.Text = dtOurCompany.Rows[0]["CompanyAddress"].ToString() + Environment.NewLine; } else { lblCompanyName.Text = "Power Protection System"; } PCSN.InvoiceSystem.BusinessLogicLayer.Salary Sal = new PCSN.InvoiceSystem.BusinessLogicLayer.Salary(); DataTable dtSalary2 = new DataTable(); dtSalary2 = Sal.GetSalaryByEmployeeID(EmployeeID); if (dtSalary2.Rows.Count > 0) { PCSN.InvoiceSystem.BusinessLogicLayer.IncreamentSalary IncreamentSalary = new PCSN.InvoiceSystem.BusinessLogicLayer.IncreamentSalary(); DataTable dtIncSal = new DataTable(); dtIncSal = IncreamentSalary.GetIncreamentSalaryBySalaryAndEmployeeID(Convert.ToInt32(dtSalary2.Rows[0]["ID"].ToString()), EmployeeID); for (int a = 0; a < dtIncSal.Rows.Count; a++) { GenerateHTML += "<tr>" + Environment.NewLine; GenerateHTML += "<td>" + Environment.NewLine; GenerateHTML += dtIncSal.Rows[a]["IncDate"].ToString() + Environment.NewLine; GenerateHTML += "</td>" + Environment.NewLine; GenerateHTML += "<td>" + Environment.NewLine; GenerateHTML += dtIncSal.Rows[a]["IncAmount"].ToString() + Environment.NewLine; GenerateHTML += "</td>" + Environment.NewLine; GenerateHTML += "<td align=\"justify\">" + Environment.NewLine; GenerateHTML += dtIncSal.Rows[a]["Description"].ToString() + Environment.NewLine; GenerateHTML += "</td>" + Environment.NewLine; GenerateHTML += "</tr>" + Environment.NewLine; } } lblCurrentSalary.Text = dtEmployeeEdit.Rows[0]["CurrentSalary"].ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["OrderMasterID"] != null && Request.QueryString["OrderMasterID"].ToString() != "") { // This is for Showing Full Invoice long OrdermasterID = Convert.ToInt32(Request.QueryString["OrderMasterID"].ToString()); //long OrderDetailID = 0; PCSN.InvoiceSystem.BusinessLogicLayer.Order Order = new PCSN.InvoiceSystem.BusinessLogicLayer.Order(); if (Request.QueryString["Title"] == null || Request.QueryString["Title"].ToString() == "") { lblMainTitle.Text = "Order Slip"; } else { lblMainTitle.Text = Request.QueryString["Title"].ToString(); } lblDetailTitle.Text = "Order Details"; dtOrderEdit = Order.GetOrderByID(OrdermasterID); if (dtOrderEdit.Rows.Count > 0) { lblOrderDate.Text = Convert.ToDateTime(dtOrderEdit.Rows[0]["OrderDate"].ToString()).ToShortDateString(); lblOrderNumber.Text = dtOrderEdit.Rows[0]["OrderNumber"].ToString(); try { lblDueDate.Text = Convert.ToDateTime(dtOrderEdit.Rows[0]["DueDate"].ToString()).ToShortDateString(); } catch { lblDueDate.Text = ""; } lblClientName.Text = dtOrderEdit.Rows[0]["ClientName"].ToString() + Environment.NewLine; lblClientCompanyName.Text = dtOrderEdit.Rows[0]["ClientCompanyName"].ToString() + Environment.NewLine; lblClientAddress.Text = dtOrderEdit.Rows[0]["ClientCompanyAddress"].ToString() + Environment.NewLine; PCSN.InvoiceSystem.BusinessLogicLayer.OurCompany ourCompany = new PCSN.InvoiceSystem.BusinessLogicLayer.OurCompany(); DataTable dtOurCompany = new DataTable(); dtOurCompany = ourCompany.GetOurCompanyByID(Convert.ToInt32("1")); if (dtOurCompany.Rows.Count > 0) { //txtOurCompanyID.Text = dtOurCompany.Rows[0]["ID"].ToString(); lblCompanyName.Text = dtOurCompany.Rows[0]["CompanyName"].ToString() + Environment.NewLine; lblAddress.Text = dtOurCompany.Rows[0]["CompanyAddress"].ToString() + Environment.NewLine; } else { lblCompanyName.Text = "Power Protection System"; } for (int a = 0; a < dtOrderEdit.Rows.Count; a++) { GenerateHTML += "<tr>" + Environment.NewLine; GenerateHTML += "<td>" + Environment.NewLine; //GenerateHTML += dtOrderEdit.Rows[a]["Item"].ToString() + Environment.NewLine; GenerateHTML += "</td>" + Environment.NewLine; GenerateHTML += "<td>" + Environment.NewLine; GenerateHTML += dtOrderEdit.Rows[a]["Item"].ToString() + Environment.NewLine; GenerateHTML += "</td>" + Environment.NewLine; GenerateHTML += "<td align=\"justify\">" + Environment.NewLine; GenerateHTML += dtOrderEdit.Rows[a]["Description"].ToString() + Environment.NewLine; GenerateHTML += "</td>" + Environment.NewLine; GenerateHTML += "<td id=\"quantity\">" + Environment.NewLine; GenerateHTML += dtOrderEdit.Rows[a]["Quantity"].ToString() + Environment.NewLine; GenerateHTML += "</td>" + Environment.NewLine; GenerateHTML += "<td id=\"rate\">" + Environment.NewLine; GenerateHTML += dtOrderEdit.Rows[a]["UnitPrice"].ToString() + Environment.NewLine; GenerateHTML += "</td>" + Environment.NewLine; GenerateHTML += "<td id=\"amount\">" + Environment.NewLine; GenerateHTML += dtOrderEdit.Rows[a]["ItemAmount"].ToString() + Environment.NewLine; GenerateHTML += "</td>" + Environment.NewLine; GenerateHTML += "</tr>" + Environment.NewLine; } lblGrandTotdal.Text = dtOrderEdit.Rows[0]["TotalAmount"].ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { //string ModeCheck = ""; if (Request.QueryString["DailyExpMasterID"] != null && Request.QueryString["DailyExpMasterID"].ToString() != "" && Request.QueryString["DailyExpDetailID"] != null && Request.QueryString["DailyExpDetailID"].ToString() != "" && !Page.IsPostBack) { // This is for Updating and ITEM in Expense long ExpenseDetailID = Convert.ToInt32(Request.QueryString["DailyExpDetailID"].ToString()); PCSN.InvoiceSystem.BusinessLogicLayer.DailyExpMaster Expense = new PCSN.InvoiceSystem.BusinessLogicLayer.DailyExpMaster(); txtItemDescID.Text = Request.QueryString["DailyExpDetailID"].ToString(); lblTotalAmount.Text = "0"; dtExpenseEdit = Expense.GetDailyExpDetailByID(ExpenseDetailID); for (int a = 0; a < dtExpenseEdit.Rows.Count; a++) { if (dtExpenseEdit.Rows[a]["ID"].ToString() == Request.QueryString["DailyExpDetailID"].ToString()) { txtItemDesc.Text = dtExpenseEdit.Rows[a]["ItemDesc"].ToString(); txtItemDescID.Text = dtExpenseEdit.Rows[a]["ID"].ToString(); txtQuantity.Text = dtExpenseEdit.Rows[a]["Quantity"].ToString(); txtUnitPrice.Text = dtExpenseEdit.Rows[a]["UnitPrice"].ToString(); txtItemAmount.Text = dtExpenseEdit.Rows[a]["ItemAmount"].ToString(); txtItemAmountPrevious.Text = dtExpenseEdit.Rows[a]["ItemAmount"].ToString(); PopulateExpenses(Convert.ToInt32(Request.QueryString["DailyExpMasterID"].ToString())); } lblTotalAmount.Text = Convert.ToString(Convert.ToInt32(lblTotalAmount.Text) + Convert.ToInt32(dtExpenseEdit.Rows[a]["ItemAmount"].ToString())); lblTotalExpOfToday.Text = lblTotalAmount.Text; } } if (!Page.IsPostBack) { PCSN.InvoiceSystem.BusinessLogicLayer.DailyExpMaster ExpM = new PCSN.InvoiceSystem.BusinessLogicLayer.DailyExpMaster(); PCSN.InvoiceSystem.BusinessLogicLayer.Closing closing = new PCSN.InvoiceSystem.BusinessLogicLayer.Closing(); DataTable dtClosing = new DataTable(); DataTable dtExpM = new DataTable(); // It is to refresh the total expense page. if (Request.QueryString["DailyExpMasterID"] != null && Request.QueryString["DailyExpMasterID"].ToString() != "") { txtDailyExpMasterID.Text = Request.QueryString["DailyExpMasterID"].ToString(); } else { dtExpM = ExpM.GetDailyExpMasterByExpDate(DateTime.Now.ToShortDateString()); if (dtExpM.Rows.Count > 0) { txtDailyExpMasterID.Text = dtExpM.Rows[0]["ID"].ToString(); lblExpenseNumber.Text = txtDailyExpMasterID.Text; } } if (txtDailyExpMasterID.Text == "") { // This will run everytime u access the Expense page, to check if it is a new Day or the closing has been made for this day?. // Checking the Closing of Today? dtClosing = closing.GetAllDailyClosingByDate(DateTime.Now.ToShortDateString()); if (dtClosing.Rows.Count > 0) { } else { // So the Closing has not been performed.. Means NO NEW EXPENSE dtExpM = ExpM.GetDailyExpMasterByExpDate(DateTime.Now.ToShortDateString()); if (dtExpM.Rows.Count > 0) { txtDailyExpMasterID.Text = dtExpM.Rows[0]["ID"].ToString(); lblExpenseNumber.Text = txtDailyExpMasterID.Text; } // Performing Closing ( IT WILL CHECK IF THE CLOSING FOR YESTERDAY IS PERFORMED OR NOT ) //============================= long DEM_ID = 0; // First we will get the EXPENSE ID of Yesterday dtExpM = ExpM.GetDailyExpMasterByExpDate(DateTime.Now.AddDays(-1).ToShortDateString()); if (dtExpM.Rows.Count > 0) { DEM_ID = Convert.ToInt32(dtExpM.Rows[0]["ID"].ToString()); } // Now we are Checking the Closing of Yesterday dtClosing = closing.GetAllDailyClosingByDate(DateTime.Now.AddDays(-1).ToShortDateString()); if (dtClosing.Rows.Count > 0 || DEM_ID == 0) { // Closing is already DONE or It was a Holiday or WeekEnd } else { // CLOSING Daily Closing of Yesterday closing.InsertDailyClosing(DateTime.Now.AddDays(-1).ToShortDateString(), DEM_ID); } //======================================== } } if (txtDailyExpMasterID.Text == "") { // This is when a Fresh Expense is About to Generate // DAILY CLOSING Is DONE for Previous day lblRemainingCash.Text = "0"; lblStartCash.Text = "0"; PCSN.InvoiceSystem.BusinessLogicLayer.OurCompany ourCompany = new PCSN.InvoiceSystem.BusinessLogicLayer.OurCompany(); dtOurCompany = ourCompany.GetOurCompanyByID(Convert.ToInt32("1")); if (dtOurCompany.Rows.Count <= 0) { txtOurCompany.Text = "PC.Solutions.NET"; } else { txtOurCompanyID.Text = dtOurCompany.Rows[0]["ID"].ToString(); txtOurCompany.Text = dtOurCompany.Rows[0]["CompanyName"].ToString() + Environment.NewLine; txtOurCompany.Text = txtOurCompany.Text + dtOurCompany.Rows[0]["CompanyAddress"].ToString() + Environment.NewLine; } lblStartCash.Text = "0"; PCSN.InvoiceSystem.BusinessLogicLayer.DailyExpMaster Expense = new PCSN.InvoiceSystem.BusinessLogicLayer.DailyExpMaster(); PCSN.InvoiceSystem.BusinessLogicLayer.CashInHand CashinHand = new PCSN.InvoiceSystem.BusinessLogicLayer.CashInHand(); DataTable dtCashinHand = new DataTable(); // Getting Cash in Hand Detail dtCashinHand = CashinHand.GetAllCashInHandByMAXID(); if (dtCashinHand.Rows.Count > 0) { txtCashInHandID.Text = dtCashinHand.Rows[0]["ID"].ToString(); dtCashinHand = CashinHand.GetAllCashInHandByDateIN(DateTime.Now.ToShortDateString()); // Getting the CASH IN HAND details of Today if (dtCashinHand.Rows.Count > 0) { if (dtCashinHand.Rows.Count > 1) { for (int i = 0; i > dtCashinHand.Rows.Count; i++) { txtCashInHandID.Text = dtCashinHand.Rows[i]["ID"].ToString(); lblStartCash.Text = Convert.ToString(Convert.ToInt32(lblStartCash.Text) + Convert.ToInt32(dtCashinHand.Rows[i]["CashIN"].ToString())); lblRemainingCash.Text = Convert.ToString(Convert.ToInt32(lblRemainingCash.Text) + Convert.ToInt32(dtCashinHand.Rows[i]["TotalAmount"].ToString())); } } else { txtCashInHandID.Text = dtCashinHand.Rows[0]["ID"].ToString(); lblStartCash.Text = dtCashinHand.Rows[0]["CashAvailable"].ToString(); lblRemainingCash.Text = dtCashinHand.Rows[0]["CashAvailable"].ToString(); } } else { dtCashinHand = CashinHand.GetAllCashInHandByMAXID(); if (dtCashinHand.Rows.Count > 0) { long CashinhandID = CashinHand.InsertCashInHand(Convert.ToInt32(dtCashinHand.Rows[0]["ChequeIssueID"].ToString()), Convert.ToInt32(dtCashinHand.Rows[0]["CashAvailable"].ToString()), Convert.ToInt32("0"), DateTime.Now.ToShortDateString(), Convert.ToInt32(dtCashinHand.Rows[0]["CashAvailable"].ToString()), "Automatic Entry to Data Base of Starting Cash in Hand for Today"); dtCashinHand = CashinHand.GetAllCashInHandByMAXID(); if (dtCashinHand.Rows.Count > 0) { txtCashInHandID.Text = dtCashinHand.Rows[0]["ID"].ToString(); lblStartCash.Text = dtCashinHand.Rows[0]["CashAvailable"].ToString(); lblRemainingCash.Text = dtCashinHand.Rows[0]["CashAvailable"].ToString(); } } } } else { Response.Redirect("CashRegister.aspx?errmsg=You do not have enough Funds available to use as Cash. Please issue a Cheque for Personal Use and then Use it in order to use Daily Expense System."); } lblHeaderDate.Text = Convert.ToString(DateTime.Now.ToShortDateString()); lblTotalAmount.Text = "0"; lblTotalExpOfToday.Text = lblTotalAmount.Text; dtExpense = Expense.GetAllDailyExpMasterMAX(); if (dtExpense.Rows.Count == 0 || dtExpense.Rows[0]["MAXID"].ToString() == "") { lblExpenseNumber.Text = "1"; } else { lblExpenseNumber.Text = Convert.ToInt32(Convert.ToInt32(dtExpense.Rows[0]["MAXID"].ToString()) + 1).ToString(); } } else { // This is when the Expense ID is getting from somewhere // AND the DAILY CLOSING has not been performed // Like from Query Strings PCSN.InvoiceSystem.BusinessLogicLayer.OurCompany ourCompany = new PCSN.InvoiceSystem.BusinessLogicLayer.OurCompany(); dtOurCompany = ourCompany.GetOurCompanyByID(Convert.ToInt32("1")); if (dtOurCompany.Rows.Count <= 0) { txtOurCompany.Text = "PC.Solutions.NET"; } else { txtOurCompanyID.Text = dtOurCompany.Rows[0]["ID"].ToString(); txtOurCompany.Text = dtOurCompany.Rows[0]["CompanyName"].ToString() + Environment.NewLine; txtOurCompany.Text = txtOurCompany.Text + dtOurCompany.Rows[0]["CompanyAddress"].ToString() + Environment.NewLine; } PCSN.InvoiceSystem.BusinessLogicLayer.CashInHand CashinHand = new PCSN.InvoiceSystem.BusinessLogicLayer.CashInHand(); DataTable dtCashinHand = new DataTable(); dtCashinHand = CashinHand.GetAllCashInHandByMAXID(); // Setting up the CASH IN HAND VALUES if (dtCashinHand.Rows.Count > 0) { txtCashInHandID.Text = dtCashinHand.Rows[0]["ID"].ToString(); } else { // If Cash in Hand Not Found then you Need to Add some Cash in Hand in order to run Daily Expense Response.Redirect("CashRegister.aspx"); } lblHeaderDate.Text = Convert.ToString(DateTime.Now.ToShortDateString()); lblTotalAmount.Text = "0"; PCSN.InvoiceSystem.BusinessLogicLayer.DailyExpMaster Expense = new PCSN.InvoiceSystem.BusinessLogicLayer.DailyExpMaster(); dtExpense = Expense.GetDailyExpMasterByID(Convert.ToInt32(txtDailyExpMasterID.Text)); if (dtExpense.Rows.Count > 0) { lblStartCash.Text = dtExpense.Rows[0]["StartCash"].ToString(); lblRemainingCash.Text = dtExpense.Rows[0]["EndCash"].ToString(); lblExpenseNumber.Text = dtExpense.Rows[0]["ID"].ToString(); lblTotalAmount.Text = dtExpense.Rows[0]["TotalAmount"].ToString(); txtCashInHandID.Text = dtExpense.Rows[0]["CashInHandID"].ToString(); lblHeaderDate.Text = dtExpense.Rows[0]["ExpDate"].ToString(); lblTotalExpOfToday.Text = lblTotalAmount.Text; lblRemainingCash.Text = Convert.ToString(Convert.ToInt32(lblStartCash.Text) - Convert.ToInt32(lblTotalExpOfToday.Text)); } if (txtDailyExpMasterID.Text != "") { PopulateExpenses(Convert.ToInt32(txtDailyExpMasterID.Text)); } } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["ExpenseMasterID"] != null && Request.QueryString["ExpenseMasterID"].ToString() != "") { // This is for Showing Full Invoice long ExpensemasterID = Convert.ToInt32(Request.QueryString["ExpenseMasterID"].ToString()); //long ExpenseDetailID = 0; PCSN.InvoiceSystem.BusinessLogicLayer.DailyExpMaster Expense = new PCSN.InvoiceSystem.BusinessLogicLayer.DailyExpMaster(); lblMainTitle.Text = "Daily Expense"; lblDailyExpTitle.Text = "Daily Expense's Detail"; dtExpense = Expense.GetDailyExpMasterByID(ExpensemasterID); if (dtExpense.Rows.Count > 0) { // Setting up Starting Values PCSN.InvoiceSystem.BusinessLogicLayer.CashInHand CashinHand = new PCSN.InvoiceSystem.BusinessLogicLayer.CashInHand(); DataTable dtCashinHand = new DataTable(); dtCashinHand = CashinHand.GetCashInHandByID(Convert.ToInt32(dtExpense.Rows[0]["CashInHandID"].ToString())); if (dtCashinHand.Rows.Count > 0) { lblCashWasInHand.Text = dtCashinHand.Rows[0]["CashIN"].ToString(); lblRemainingCash.Text = dtCashinHand.Rows[0]["CashAvailable"].ToString(); } lblCashWasInHand.Text = dtExpense.Rows[0]["StartCash"].ToString(); lblRemainingCash.Text = dtExpense.Rows[0]["EndCash"].ToString(); lblGrandTotal.Text = dtExpense.Rows[0]["TotalAmount"].ToString(); lblExpDate.Text = dtExpense.Rows[0]["ExpDate"].ToString(); lblExpOfTheDay.Text = dtExpense.Rows[0]["TotalAmount"].ToString(); //Setting up Our Company Details PCSN.InvoiceSystem.BusinessLogicLayer.OurCompany ourCompany = new PCSN.InvoiceSystem.BusinessLogicLayer.OurCompany(); DataTable dtOurCompany = new DataTable(); dtOurCompany = ourCompany.GetOurCompanyByID(Convert.ToInt32("1")); if (dtOurCompany.Rows.Count > 0) { //txtOurCompanyID.Text = dtOurCompany.Rows[0]["ID"].ToString(); lblCompanyName.Text = dtOurCompany.Rows[0]["CompanyName"].ToString() + Environment.NewLine; lblAddress.Text = dtOurCompany.Rows[0]["CompanyAddress"].ToString() + Environment.NewLine; } else { lblCompanyName.Text = "Power Protection System"; } // Setting Up Each Expense for (int a = 0; a < dtExpense.Rows.Count; a++) { GenerateHTML += "<tr>" + Environment.NewLine; GenerateHTML += "<td>" + Environment.NewLine; GenerateHTML += dtExpense.Rows[a]["ItemDesc"].ToString() + Environment.NewLine; GenerateHTML += "</td>" + Environment.NewLine; GenerateHTML += "<td id=\"quantity\">" + Environment.NewLine; GenerateHTML += dtExpense.Rows[a]["Quantity"].ToString() + Environment.NewLine; GenerateHTML += "</td>" + Environment.NewLine; GenerateHTML += "<td id=\"rate\">" + Environment.NewLine; GenerateHTML += dtExpense.Rows[a]["UnitPrice"].ToString() + Environment.NewLine; GenerateHTML += "</td>" + Environment.NewLine; GenerateHTML += "<td id=\"amount\">" + Environment.NewLine; GenerateHTML += dtExpense.Rows[a]["ItemAmount"].ToString() + Environment.NewLine; GenerateHTML += "</td>" + Environment.NewLine; GenerateHTML += "</tr>" + Environment.NewLine; } lblGrandTotal.Text = dtExpense.Rows[0]["TotalAmount"].ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["OrderMasterID"] != null && Request.QueryString["OrderMasterID"].ToString() != "" && Request.QueryString["OrderDetailID"] != null && Request.QueryString["OrderDetailID"].ToString() != "" && !Page.IsPostBack) { // This is for Updating and ITEM in Order long OrdermasterID = Convert.ToInt32(Request.QueryString["OrderMasterID"].ToString()); PCSN.InvoiceSystem.BusinessLogicLayer.Order Order = new PCSN.InvoiceSystem.BusinessLogicLayer.Order(); txtOrderMasterID.Text = Request.QueryString["OrderMasterID"].ToString(); lblTotalAmount.Text = "0"; dtOrderEdit = Order.GetOrderByID(OrdermasterID); for (int a = 0; a < dtOrderEdit.Rows.Count; a++) { if (dtOrderEdit.Rows[a]["OrderDetailID"].ToString() == Request.QueryString["OrderDetailID"].ToString()) { lblDetailDate.Text = Convert.ToDateTime(dtOrderEdit.Rows[a]["OrderDate"].ToString()).ToShortDateString(); txtItem.Text = dtOrderEdit.Rows[a]["Item"].ToString(); txtItemID.Text = dtOrderEdit.Rows[a]["OrderDetailID"].ToString(); txtDescription.Text = dtOrderEdit.Rows[a]["Description"].ToString(); txtQuantity.Text = dtOrderEdit.Rows[a]["Quantity"].ToString(); txtUnitPrice.Text = dtOrderEdit.Rows[a]["UnitPrice"].ToString(); txtItemAmount.Text = dtOrderEdit.Rows[a]["ItemAmount"].ToString(); cboClientList.SelectedValue = dtOrderEdit.Rows[a]["ClientID"].ToString(); txtDueDate.Text = Convert.ToDateTime(dtOrderEdit.Rows[a]["DueDate"].ToString()).ToShortDateString(); //lblTotalAmount.Text = dtOrderEdit.Rows[a]["TotalAmount"].ToString(); if (dtOrderEdit.Rows[a]["ID"].ToString() != "") { PopulateOrders(Convert.ToInt32(dtOrderEdit.Rows[a]["ID"].ToString())); } } lblTotalAmount.Text = Convert.ToString(Convert.ToInt32(lblTotalAmount.Text) + Convert.ToInt32(dtOrderEdit.Rows[a]["ItemAmount"].ToString())); } } if (!Page.IsPostBack) { if (Request.QueryString["OrderMasterIDEdit"] != null && Request.QueryString["OrderMasterIDEdit"].ToString() != "") { txtOrderMasterID.Text = Request.QueryString["OrderMasterIDEdit"].ToString(); } // txtOrderMasterID.Text = "16"; if (txtOrderMasterID.Text == "") { // This is when a Fresh Order is About to GeneUnitPrice txtClient.Text = "Please Select a Client from Above List"; PCSN.InvoiceSystem.BusinessLogicLayer.OurCompany ourCompany = new PCSN.InvoiceSystem.BusinessLogicLayer.OurCompany(); dtOurCompany = ourCompany.GetOurCompanyByID(Convert.ToInt32("1")); if (dtOurCompany.Rows.Count <= 0) { txtOurCompany.Text = "PC.Solutions.NET"; } else { txtOurCompanyID.Text = dtOurCompany.Rows[0]["ID"].ToString(); txtOurCompany.Text = dtOurCompany.Rows[0]["CompanyName"].ToString() + Environment.NewLine; txtOurCompany.Text = txtOurCompany.Text + dtOurCompany.Rows[0]["CompanyAddress"].ToString() + Environment.NewLine; } lblHeaderDate.Text = Convert.ToString(DateTime.Now.ToShortDateString()); lblDetailDate.Text = Convert.ToString(DateTime.Now.ToShortDateString()); PCSN.InvoiceSystem.BusinessLogicLayer.Order Order = new PCSN.InvoiceSystem.BusinessLogicLayer.Order(); dtOrder = Order.GetAllOrderMAX(); if (dtOrder.Rows.Count == 0 || dtOrder.Rows[0]["ID"].ToString() == "") { lblOrderNumber.Text = "1"; } else { lblOrderNumber.Text = Convert.ToInt32(Convert.ToInt32(dtOrder.Rows[0]["ID"].ToString()) + 1).ToString(); } if (txtOrderMasterID.Text != "") { PopulateOrders(Convert.ToInt32(txtOrderMasterID.Text)); } PopulateClients(); } else { // This is when the Order ID is getting from somewhere // Like from Query Strings long OrdermasterID = Convert.ToInt32(txtOrderMasterID.Text.ToString()); lblOrderNumber.Text = OrdermasterID.ToString(); PopulateClients(); PopulateOrders(OrdermasterID); PCSN.InvoiceSystem.BusinessLogicLayer.Order Order = new PCSN.InvoiceSystem.BusinessLogicLayer.Order(); lblTotalAmount.Text = "0"; dtOrderEdit = Order.GetOrderByID(OrdermasterID); for (int a = 0; a < dtOrderEdit.Rows.Count; a++) { if (dtOrderEdit.Rows[a]["ItemAmount"].ToString() == null || dtOrderEdit.Rows[a]["ItemAmount"].ToString() == "") { } else { lblTotalAmount.Text = Convert.ToString(Convert.ToInt32(lblTotalAmount.Text) + Convert.ToInt32(dtOrderEdit.Rows[a]["ItemAmount"].ToString())); } } if (dtOrderEdit.Rows.Count > 0) { //PopulateOrders(Convert.ToInt32(dtOrderEdit.Rows[0]["ID"].ToString())); PCSN.InvoiceSystem.BusinessLogicLayer.Client client = new PCSN.InvoiceSystem.BusinessLogicLayer.Client(); dtClient = client.GetClientByID(Convert.ToInt32(dtOrderEdit.Rows[0]["ClientID"].ToString())); if (dtClient.Rows.Count <= 0) { txtClient.Text = "Our Client"; } else { cboClientList.SelectedValue = dtClient.Rows[0]["ID"].ToString(); txtClientID.Text = dtClient.Rows[0]["ID"].ToString(); txtClient.Text = dtClient.Rows[0]["ClientName"].ToString() + Environment.NewLine; txtClient.Text = txtClient.Text + dtClient.Rows[0]["CompanyName"].ToString() + Environment.NewLine; txtClient.Text = txtClient.Text + dtClient.Rows[0]["Address"].ToString() + Environment.NewLine; } txtOurCompanyID.Text = "1"; txtOurCompany.Text = "Power Protection Services" + Environment.NewLine; txtOurCompany.Text = txtOurCompany.Text + "XYZ Address" + Environment.NewLine; lblHeaderDate.Text = Convert.ToString(Convert.ToDateTime(dtOrderEdit.Rows[0]["OrderDate"].ToString()).ToShortDateString()); txtDueDate.Text = Convert.ToString(Convert.ToDateTime(dtOrderEdit.Rows[0]["DueDate"].ToString()).ToShortDateString()); lblDetailDate.Text = Convert.ToString(Convert.ToDateTime(dtOrderEdit.Rows[0]["OrderDate"].ToString()).ToShortDateString()); } } } }