private void buttonSaveOrder_Click_1(object sender, EventArgs e) { List <Orders> listO = OrderDA.ListOrder(); if (IsValidOrderData()) { Inventory product = InventoryDA.Search(Convert.ToInt32(textBoxISBN.Text)); Client client = ClientDA.Search(Convert.ToInt32(comboBoxClientID.Text)); string isbn = textBoxISBN.Text; int quantityproduct = Convert.ToInt32(textBoxOQty.Text); int id = (Convert.ToInt32(comboBoxClientID.Text)); if (product == null) { MessageBox.Show("Wrong Information product, try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (product.ProductQuantity < Convert.ToInt32(textBoxOQty.Text)) { MessageBox.Show("We do not have the quantity required on Inventory", "Missing Product"); textBoxOQty.Clear(); return; } else { if (client.ClientID == (Convert.ToInt32(comboBoxClientID.Text))) { textBoxClientName.Text = client.InstitutionName; } Int32 quantityselected = Convert.ToInt32(textBoxOQty.Text); Double priceselected = Convert.ToDouble(textBoxProductPrice.Text); Double finalamout = quantityselected * priceselected; textBoxFinalAmount.Text = finalamout.ToString(); Orders aOrder = new Orders(); aOrder.OrderNumber = Convert.ToInt32(textBoxOnumber.Text); aOrder.ISBNProduct = Convert.ToInt32(textBoxISBN.Text); aOrder.ProductTitle = textBoxOProductTitle.Text; aOrder.ProductDescription = textBoxProductDescription.Text; aOrder.ClientID = (Convert.ToInt32(comboBoxClientID.Text)); aOrder.ClientName = textBoxClientName.Text; aOrder.OrderDate = dateTimePickerOdate.Text; aOrder.ShippingDate = dateTimePickerSDate.Text; aOrder.OrderQuantity = Convert.ToInt32(textBoxOQty.Text); aOrder.ProductPrice = Convert.ToDouble(textBoxProductPrice.Text); aOrder.FinalAmount = Convert.ToDouble(textBoxFinalAmount.Text); OrderDA.Save(aOrder); listO.Add(aOrder); ClearAll(); } } }
public IHttpActionResult UpdateClient([FromBody]ClientDTO client) { try { clientDA = new ClientDA(); clientDA.CreateClient(client); return Ok(); } catch (System.Exception ex) { return InternalServerError(ex); } }
public IHttpActionResult GetClients() { try { clientDA = new ClientDA(); return Ok(clientDA.GetClients()); } catch (Exception ex) { return InternalServerError(ex); } }
private void buttonDeleteClient_Click(object sender, EventArgs e) { if (IsValidClientData()) { DialogResult ans = MessageBox.Show("Do you really want to delete this Client?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (ans == DialogResult.Yes) { ClientDA.Delete(Convert.ToInt32(textBoxClientID.Text)); MessageBox.Show("Client record has been deleted successfully", "Confirmation"); ClearAll(); textBoxClientID.Focus(); textBoxClientID.Enabled = true; } } }
private string GetDemographicInfo(DataRow dr) { string result; string citizen = "<b>US Citizenship: </b> " + dsReport.Tables["DemCitizen"].Rows.Find(dr["DemCitizenID"])["DemCitizen"].ToString() + "<br />"; string gender = "<b>Gender: </b> " + dsReport.Tables["DemGender"].Rows.Find(dr["DemGenderID"])["DemGender"].ToString() + "<br />"; string race = "<b>Race: </b> " + dsReport.Tables["DemRace"].Rows.Find(dr["DemRaceID"])["DemRace"].ToString() + "<br />"; string ethnic = "<b>Ethnicity: </b> " + dsReport.Tables["DemEthnic"].Rows.Find(dr["DemEthnicID"])["DemEthnic"].ToString() + "<br />"; string disability = "<b>Disability: </b> " + dsReport.Tables["DemDisability"].Rows.Find(dr["DemDisabilityID"])["DemDisability"].ToString() + "<br />"; string techInterest = "<b>Technical Interest: </b> " + ClientDA.GetTechnicalInterestByClientID(Convert.ToInt32(dr["ClientID"])) + "<br />"; result = citizen + gender + race + ethnic + disability + techInterest; return(result); }
//Delete private void buttonClDel_Click(object sender, EventArgs e) { DialogResult ans = MessageBox.Show("Are you sure you want to delete the Client information?", "Delete Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (ans == DialogResult.Yes) { if (OrderDA.SearchByClientID(Convert.ToInt32(textBoxClID.Text)) != null) { MessageBox.Show("This client has open orders in the system, please verify the orders before deleting this client.", "ALERT!"); return; } ClientDA.Delete(Convert.ToInt32(textBoxClID.Text)); ClientDA.List(listViewSales); UpdateComboBoxes(); } }
private void buttonSearch_Click(object sender, EventArgs e) { { int choice = comboBoxSearchClient.SelectedIndex; switch (choice) { case -1: // The user didn't select any search option MessageBox.Show("Please select the search option"); break; case 0: //The user selected the search by Customer ID if (textBoxInfoClient.Text == "") { MessageBox.Show("You have to enter Client ID, try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (Validation.IsInteger(textBoxInfoClient)) { Client client = ClientDA.Search(Convert.ToInt32(textBoxInfoClient.Text)); if (client != null) { textBoxClientID.Text = (client.ClientID).ToString(); textBoxInstitutionName.Text = client.InstitutionName; textBoxInstitutionAddress.Text = client.InstitutionAddress; textBoxInstitutionCity.Text = client.InstitutionCity; textBoxZipCode.Text = client.InstitutionZipCode; textBoxEmailClient.Text = client.InstitutionEmail; maskedTextBoxPhoneClient.Text = client.InstitutionPhoneNumber; textBoxInfoClient.Clear(); textBoxClientID.Enabled = false; } else { MessageBox.Show("Client ID not found, try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxInfoClient.Clear(); textBoxInfoClient.Focus(); } } } break; default: break; } } }
public ActionResult LoginCallback(string returnUrl) { SystemUserLoginItemExtend item = new SystemUserLoginItemExtend() { Remember = true, ReturnUrl = returnUrl, Provider = GetDomain(returnUrl) }; if (User != null) { SystemUserLoginItem user = new SystemUserLoginItem(); user.UserName = User.Account; user.Provider = GetDomain(returnUrl); #region Xử lý nếu User đã đăng xuất tại client var clientDA = new ClientDA(); var client = clientDA.GetByDomain(user.Provider); //lấy ra client mà user đang sử dụng if (client != null) { var userClientDa = new UserClientDA(); var userClient = userClientDa.GetListByUsernameAndClientId(User.Account, client.Id); if (userClient != null) //check nếu user có account của client đấy không { if (userClient.IsLogin == false) { ViewBag.ReturnUrl = returnUrl; return(View(item)); } } else { return(Redirect(returnUrl)); } } #endregion if (!string.IsNullOrEmpty(returnUrl)) { return(Redirect(string.Format("{0}{1}{2}", returnUrl, "?data=", HttpUtility.UrlEncode(GetReturnData(user))))); } else { return(Redirect(ConfigurationManager.AppSettings["DefaultReturnUrl"])); } } ViewBag.ReturnUrl = returnUrl; return(View(item)); }
//Add private void buttonOrdAdd_Click(object sender, EventArgs e) { Validator checker = new Validator(); if (checker.isNotNull(comboBoxOrdClient.Text, "Client") && checker.isNotNull(comboBoxOrdISBN.Text, "Book ISBN") && checker.isNotNull(textBoxOrdBkQt.Text, "Quantity") && checker.isNotNull(comboBoxOrdMadeBy.Text, "Order made by?")) { Order aorder = createOrder(); Book abook = BookDA.SearchISBN(Convert.ToInt64(comboBoxOrdISBN.Text)); Client aclient = ClientDA.SearchName(comboBoxOrdClient.Text); abook.BkQOH = abook.BkQOH - aorder.OrdBkQuantity; BookDA.Update(abook); aclient.ClientCredit = aclient.ClientCredit - aorder.OrdCost; ClientDA.Update(aclient); OrderDA.SaveOrder(aorder); UpdateComboBoxes(); } }
//Update private void buttonOrdUpd_Click(object sender, EventArgs e) { Order aorder = createOrder(); Order oldorder = OrderDA.SearchID(Convert.ToInt32(textBoxOrId.Text)); Book abook = BookDA.SearchISBN(Convert.ToInt64(comboBoxOrdISBN.Text)); Client aclient = ClientDA.SearchName(comboBoxOrdClient.Text); abook.BkQOH = (abook.BkQOH + oldorder.OrdBkQuantity) - aorder.OrdBkQuantity; BookDA.Update(abook); aclient.ClientCredit = (aclient.ClientCredit + aorder.OrdCost) - aorder.OrdCost; ClientDA.Update(aclient); OrderDA.Update(aorder); OrderDA.ListOrder(listViewOrder); UpdateComboBoxes(); }
public ResultEntity <int> DeleteById(int id) { var validationResult = new ResultEntity <int>(); using (var clientDA = new ClientDA()) { //var ids = new int[] { id }; validationResult.Value = clientDA.Delete(id); if (validationResult.Value != 1) { validationResult.Warning.Add("Failed delete record Client with ID: " + id); return(validationResult); } } return(validationResult); }
private void buttonAddToList_Click(object sender, EventArgs e) { Client client = new Client(); if (ClientValidation.isValidID(textboxClientId) && ClientValidation.isValidName(texbBoxClientName) && ClientValidation.isValidValues(textboxStreet) && ClientValidation.isValidValues(textboxCity) && ClientValidation.isValidValues(textboxPostalCode) && ClientValidation.isValidValues(textboxFaxNumber) && ClientValidation.isValidValues(textboxCreditLimit)) { client.ClientID = Convert.ToInt32(textboxClientId.Text); client.Name = texbBoxClientName.Text; client.Street = textboxStreet.Text; client.City = textboxCity.Text; client.PostalCode = textboxPostalCode.Text; client.PhoneNumber = maskedtextboxPhoneNumber.Text; client.FaxNumber = textboxFaxNumber.Text; client.CreditLimit = Convert.ToInt32(textboxCreditLimit.Text); ClientDA.Add(client); ClearAll(); } }
//Enable the buttons delete and update in case of a valid entered ID private void textBoxClID_TextChanged(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxClID.Text)) { buttonClDel.Enabled = false; buttonClUpdate.Enabled = false; return; } if (ClientDA.SearchID(Convert.ToInt32(textBoxClID.Text)) != null) { buttonClDel.Enabled = true; buttonClUpdate.Enabled = true; return; } buttonClDel.Enabled = false; buttonClUpdate.Enabled = false; }
public ResultEntity <ClientEntity> Update(ClientEntity clientEntity) { var validationResult = new ResultEntity <ClientEntity>(); using (var clientDA = new ClientDA()) { var resultUpdate = clientDA.Update(clientEntity); if (resultUpdate <= 0) { validationResult.Warning.Add("Failed Updating Client!"); return(validationResult); } validationResult.Value = clientEntity; } return(validationResult); }
//===================================================================================================================================== //=============================END OF INVENTORY MANAGER PROGRAM======================================================================== //===================================================================================================================================== //===================================================================================================================================== //=============================BEGINNING OF ORDER CLERKS PROGRAM======================================================================= //===================================================================================================================================== // Create object Order private Order createOrder() { Order aorder = new Order(); Book abook = new Book(); Client aclient = new Client(); abook = BookDA.SearchISBN(Convert.ToInt64(comboBoxOrdISBN.Text)); aclient = ClientDA.SearchName(comboBoxOrdClient.Text); aorder.OrdId = OrderDA.OrderID() + 1; aorder.OrdClient = aclient; aorder.OrdBbook = abook; aorder.OrdBkQuantity = Convert.ToInt32(textBoxOrdBkQt.Text); aorder.OrdCost = aorder.OrdBkQuantity * BookDA.SearchISBN(Convert.ToInt64(comboBoxOrdISBN.Text)).BkUnitPrice; aorder.OrdDate = Convert.ToDateTime(dateTimePickerOrder.Value); aorder.OrdType = comboBoxOrdMadeBy.Text; textBoxOrId.Text = aorder.OrdId.ToString(); return(aorder); }
//Search private void buttonClSearch_Click(object sender, EventArgs e) { Client aclient = new Client(); if (!string.IsNullOrEmpty(textBoxClSearch.Text)) { switch (comboBoxClSearch.SelectedIndex) { case -1: MessageBox.Show("Please select a valid search option!"); return; case 0: int tempId; if (!int.TryParse(textBoxClSearch.Text, out tempId)) { MessageBox.Show("Please enter a valid term to be searched.", "No search information!"); return; } aclient = ClientDA.SearchID(Convert.ToInt32(textBoxClSearch.Text)); break; case 1: aclient = ClientDA.SearchName(textBoxClSearch.Text); break; } if (aclient == null) { MessageBox.Show("Client not found!", "Not found!"); textBoxClSearch.Clear(); textBoxClSearch.Focus(); return; } ClientDA.ListSearch(aclient, listViewSales); return; } MessageBox.Show("Please enter a valid term to be searched.", "No search information!"); return; }
private void buttonAddClient_Click(object sender, EventArgs e) { if (Validator.IsValidID(textBoxClientId)) { Client client = new Client(); client.clientId = Convert.ToInt32(textBoxClientId.Text); client.name = textBoxName.Text; client.phoneNumber = maskedTextBoxPhone.Text; client.faxNumber = textBoxFax.Text; client.address = textBoxAddress.Text; client.city = textBoxCity.Text; client.postalCode = textBoxPostalCode.Text; client.bankNumber = Convert.ToInt32(textBoxBankNumber.Text); client.branchNumber = Convert.ToInt32(textBoxBranch.Text); client.bankAccount = textBoxAccountType.Text; listClient.Add(client); ClientDA.Save(client); buttonListBook.Enabled = true; ClearAll(); } }
//Delete private void buttonOrdDel_Click(object sender, EventArgs e) { DialogResult ans = MessageBox.Show("Are you sure you want to delete this Order?", "Delete Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (ans == DialogResult.Yes) { OrderDA.Delete(Convert.ToInt32(textBoxOrId.Text)); int bkQuantity = OrderDA.SearchID(Convert.ToInt32(textBoxOrId.Text)).OrdBkQuantity; decimal ordCost = OrderDA.SearchID(Convert.ToInt32(textBoxOrId.Text)).OrdCost; Book abook = new Book(); Client aclient = new Client(); abook = BookDA.SearchISBN(Convert.ToInt64(comboBoxOrdISBN.Text)); aclient = ClientDA.SearchName(comboBoxOrdClient.Text); abook.BkQOH = abook.BkQOH + bkQuantity; aclient.ClientCredit = aclient.ClientCredit + ordCost; OrderDA.ListOrder(listViewOrder); UpdateComboBoxes(); } }
private void buttonSaveClient_Click(object sender, EventArgs e) { List <Client> listC = ClientDA.ListClient(); if (IsValidClientData()) { if (!Validation.IsUniqueClientID(listC, Convert.ToInt32(textBoxClientID.Text))) { MessageBox.Show(" DUPLICATE ", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Stop); textBoxClientID.Clear(); textBoxClientID.Focus(); return; } if (!Validation.IsUniqueClientName(listC, textBoxInstitutionName.Text)) { MessageBox.Show(" DUPLICATE ", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Stop); textBoxInstitutionName.Clear(); textBoxInstitutionName.Focus(); return; } else { Client aClient = new Client(); aClient.ClientID = Convert.ToInt32(textBoxClientID.Text); aClient.InstitutionName = textBoxInstitutionName.Text; aClient.InstitutionAddress = textBoxInstitutionAddress.Text; aClient.InstitutionCity = textBoxInstitutionCity.Text; aClient.InstitutionZipCode = textBoxZipCode.Text; aClient.InstitutionPhoneNumber = maskedTextBoxPhoneClient.Text; aClient.InstitutionEmail = textBoxEmailClient.Text; ClientDA.Save(aClient); listC.Add(aClient); buttonListClient.Enabled = true; ClearAll(); } } }
private void buttonUpdateClient_Click(object sender, EventArgs e) { List <Client> listC = ClientDA.ListClient(); if (IsValidClientData()) { Client Client = new Client(); Client.ClientID = Convert.ToInt32(textBoxClientID.Text); Client.InstitutionName = textBoxInstitutionName.Text; Client.InstitutionAddress = textBoxInstitutionAddress.Text; Client.InstitutionCity = textBoxInstitutionCity.Text; Client.InstitutionZipCode = textBoxZipCode.Text; Client.InstitutionPhoneNumber = maskedTextBoxPhoneClient.Text; Client.InstitutionEmail = textBoxEmailClient.Text; DialogResult ans = MessageBox.Show("Do you really want to update this Client?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (ans == DialogResult.Yes) { ClientDA.Update(Client); MessageBox.Show("Client record has been updated successfully", "Confirmation"); ClearAll(); textBoxClientID.Enabled = true; } } }
protected override void FillDataTable(DataTable dt) { BillingUnit summaryUnit = summaryUnits.First(); Compile mCompile = new Compile(); DataTable dtRoomDB = mCompile.CalcCost("Room", string.Empty, "ChargeTypeID", 5, EndPeriod.AddMonths(-1), 0, 0, Compile.AggType.CliAcctType); DataTable dtClientWithCharges = mCompile.GetTable(1); double roomCapCost = mCompile.CapCost; //***************************************************************************** //2008-01-22 The code below is an EXTRA step for calculating the cost of room charge // Right now the strategy is not to change Compile.CalcCost at all and if I want to // add new features that would affect CalcCost, I would rather do it after CalcCost is called. // But future new design is required else the system will get too complicated. //2208-05-15 the reason why we are doing this extra step is to show NAP rooms (as of now, it's DC Test lab and Chem room) //with correct monthly fee on the JE //dtNAPRoomForAllChargeType's columns //CostID //ChargeTypeID //TableNameOrDescript //RoomID //AcctPer //AddVal //RoomCost //effDate //Get all active NAP Rooms with their costs, all chargetypes are returned //This is a temporary table, it's used to derive the really useful table below DataTable dtNAPRoomForAllChargeType = BLL.RoomManager.GetAllNAPRoomsWithCosts(EndPeriod); //filter out the chargetype so that we only have Internal costs with each NAP room DataRow[] drsNAPRoomForInternal = dtNAPRoomForAllChargeType.Select("ChargeTypeID = 5"); //Loop through each room and find out this specified month's apportionment data. foreach (DataRow dr1 in drsNAPRoomForInternal) { DataTable dtApportionData = BLL.RoomApportionDataManager.GetNAPRoomApportionDataByPeriod(StartPeriod, EndPeriod, dr1.Field <int>("RoomID")); foreach (DataRow dr2 in dtApportionData.Rows) { DataRow[] drs = dtRoomDB.Select(string.Format("ClientID = {0} AND AccountID = {1} AND RoomID = {2}", dr2["ClientID"], dr2["AccountID"], dr2["RoomID"])); if (drs.Length == 1) { drs[0].SetField("TotalCalcCost", (dr2.Field <double>("Percentage") * dr1.Field <double>("RoomCost")) / 100); } } } dtRoomDB.Columns.Add("DebitAccount", typeof(string)); dtRoomDB.Columns.Add("CreditAccount", typeof(string)); dtRoomDB.Columns.Add("LineDesc", typeof(string)); dtRoomDB.Columns.Add("TotalAllAccountCost", typeof(double)); //dtRoom - ClientID, AccountID, RoomID, TotalCalCost, TotalEntries, TotalHours // cap costs - capping is per clientorg, thus apportion cappeing across charges // note that this assumes that there is only one org for internal academic!!! object temp; double totalRoomCharges; foreach (DataRow drCWC in dtClientWithCharges.Rows) { temp = dtRoomDB.Compute("SUM(TotalCalcCost)", string.Format("ClientID = {0}", drCWC["ClientID"])); if (temp == null || temp == DBNull.Value) { totalRoomCharges = 0; } else { totalRoomCharges = Convert.ToDouble(temp); } if (totalRoomCharges > roomCapCost) { DataRow[] fdr = dtRoomDB.Select(string.Format("ClientID = {0}", drCWC["ClientID"])); for (int i = 0; i < fdr.Length; i++) { fdr[i].SetField("TotalCalcCost", fdr[i].Field <double>("TotalCalcCost") * roomCapCost / totalRoomCharges); } } } DataTable dtClient = ClientDA.GetAllClient(StartPeriod, EndPeriod); DataTable dtAccount = AccountDA.GetAllInternalAccount(StartPeriod, EndPeriod); DataTable dtClientAccount = ClientDA.GetAllClientAccountWithManagerName(StartPeriod, EndPeriod); //used to find out manager's name //Get the general lab account ID and lab credit account ID GlobalCost gc = GlobalCostDA.GetGlobalCost(); //2008-05-15 very complicated code - trying to figure out the percentage distribution for monthly users, since the "TotalCalcCost" has //been calculated based on percentage in the CalcCost function, so we need to figure out the percentage here again by findind out the total //and divide the individual record's "TotalCalcCost' foreach (DataRow drCWC in dtClientWithCharges.Rows) { DataRow[] fdr = dtRoomDB.Select(string.Format("ClientID = {0} AND RoomID = {1}", drCWC["ClientID"], (int)BLL.LabRoom.CleanRoom)); if (fdr.Length > 1) { //this user has multiple account for the clean room usage, so we have to find out the total of all accounts on this clean room double tempTotal = Convert.ToDouble(dtRoomDB.Compute("SUM(TotalCalcCost)", string.Format("ClientID = {0} AND RoomID = {1}", drCWC["ClientID"], (int)BLL.LabRoom.CleanRoom))); DataRow[] fdrRoom = dtRoomDB.Select(string.Format("ClientID = {0} AND RoomID = {1}", drCWC["ClientID"], (int)BLL.LabRoom.CleanRoom)); for (int i = 0; i < fdrRoom.Length; i++) { fdrRoom[i].SetField("TotalAllAccountCost", tempTotal); //assign the total to each record } } } //2008-08-28 Get Billing Type DataTable dtBillingType = BillingTypeDA.GetAllBillingTypes(); foreach (DataRow dr in dtRoomDB.Rows) { dr["DebitAccount"] = dtAccount.Rows.Find(dr.Field <int>("AccountID"))["Number"]; dr["CreditAccount"] = dtAccount.Rows.Find(gc.LabCreditAccountID)["Number"]; //2007-06-19 financial manager may not be an administrator, but their username must be on JE dr["LineDesc"] = GetLineDesc(dr, dtClient, dtBillingType); //2008-05-15 the code below handles the clean room monthly users - it's special code that we have to get rid of when all //billingtype are all gone int billingTypeId = dr.Field <int>("BillingType"); if (dr.Field <BLL.LabRoom>("RoomID") == BLL.LabRoom.CleanRoom) //6 is clean room { if (BillingTypes.IsMonthlyUserBillingType(billingTypeId)) { if (dr["TotalAllAccountCost"] == DBNull.Value) { //if TotalAllAccountCost is nothing, it means this user has only one account //2008-10-27 but it might also that the user has only one internal account, and he apportion all hours to his external accouts //so we must also check 'TotalHours' to make sure the user has more than 0 hours if (dr.Field <double>("TotalHours") != 0) { dr.SetField("TotalCalcCost", BLL.BillingTypeManager.GetTotalCostByBillingType(billingTypeId, 0, 0, BLL.LabRoom.CleanRoom, 1315)); } } else { double total = dr.Field <double>("TotalAllAccountCost"); dr.SetField("TotalCalcCost", (dr.Field <double>("TotalCalcCost") / total) * BLL.BillingTypeManager.GetTotalCostByBillingType(billingTypeId, 0, 0, BLL.LabRoom.CleanRoom, 1315)); } } } } //****** apply filters ****** //Get the list below so that we can exclude users who spent less than X minutes in lab(Clean or Chem) in this month DataTable dtlistClean = RoomUsageData.GetUserListLessThanXMin(StartPeriod, EndPeriod, int.Parse(ConfigurationManager.AppSettings["CleanRoomMinTimeMinute"]), "CleanRoom"); DataTable dtlistChem = RoomUsageData.GetUserListLessThanXMin(StartPeriod, EndPeriod, int.Parse(ConfigurationManager.AppSettings["ChemRoomMinTimeMinute"]), "ChemRoom"); //For performance issue, we have to calculate something first, since it's used on all rows string depRefNum = string.Empty; double fTotal = 0; string creditAccount = dtAccount.Rows.Find(gc.LabCreditAccountID)["Number"].ToString(); string creditAccountShortCode = dtAccount.Rows.Find(gc.LabCreditAccountID)["ShortCode"].ToString(); //Do not show an item if the charge and xcharge accounts are the 'same' - can only happen for 941975 //Do not show items that are associated with specific accounts - need to allow users to add manually here in future foreach (DataRow sdr in dtRoomDB.Rows) { if (sdr.Field <double>("TotalCalcCost") > 0) { var excludedAccounts = new[] { gc.LabAccountID, 143, 179, 188 }; if (!excludedAccounts.Contains(sdr.Field <int>("AccountID")) && sdr.Field <int>("BillingType") != BillingTypes.Other) { //2006-12-21 get rid of people who stayed in the lab less than 30 minutes in a month string expression = string.Format("ClientID = {0}", sdr["ClientID"]); DataRow[] foundRows; bool flag = false; if (sdr.Field <BLL.LabRoom>("RoomID") == BLL.LabRoom.CleanRoom) //6 = clean room { foundRows = dtlistClean.Select(expression); } else if (sdr.Field <BLL.LabRoom>("RoomID") == BLL.LabRoom.ChemRoom) //25 = chem room { foundRows = dtlistChem.Select(expression); } else //DCLab { foundRows = null; } if (foundRows == null) { flag = true; //add to the SUB } else { if (foundRows.Length == 0) { flag = true; } } if (flag) //if no foundrow, we can add this client to JE { DataRow ndr = dt.NewRow(); DataRow drAccount = dtAccount.Rows.Find(sdr.Field <int>("AccountID")); string debitAccount = drAccount["Number"].ToString(); string shortCode = drAccount["ShortCode"].ToString(); //get manager's name DataRow[] drClientAccount = dtClientAccount.Select(string.Format("AccountID = {0}", sdr["AccountID"])); if (drClientAccount.Length > 0) { depRefNum = drClientAccount[0]["ManagerName"].ToString(); } else { depRefNum = "No Manager Found"; } AccountNumber debitAccountNum = AccountNumber.Parse(debitAccount); ndr["CardType"] = 1; ndr["ShortCode"] = shortCode; ndr["Account"] = debitAccountNum.Account; ndr["FundCode"] = debitAccountNum.FundCode; ndr["DeptID"] = debitAccountNum.DeptID; ndr["ProgramCode"] = debitAccountNum.ProgramCode; ndr["Class"] = debitAccountNum.Class; ndr["ProjectGrant"] = debitAccountNum.ProjectGrant; ndr["VendorID"] = "0000456136"; ndr["InvoiceDate"] = EndPeriod.AddMonths(-1).ToString("yyyy/MM/dd"); ndr["InvoiceID"] = $"{ReportSettings.CompanyName} Room Charge"; ndr["Uniqname"] = dtClient.Rows.Find(sdr.Field <int>("ClientID"))["UserName"]; ndr["DepartmentalReferenceNumber"] = depRefNum; ndr["ItemDescription"] = GetItemDesc(sdr, dtClient, dtBillingType); ndr["QuantityVouchered"] = "1.0000"; double chargeAmount = Math.Round(sdr.Field <double>("TotalCalcCost"), 5); ndr["UnitOfMeasure"] = chargeAmount; ndr["MerchandiseAmount"] = Math.Round(chargeAmount, 2); ndr["CreditAccount"] = creditAccount; //Used to calculate the total credit amount fTotal += chargeAmount; dt.Rows.Add(ndr); } } } } //Summary row summaryUnit.CardType = 1; summaryUnit.ShortCode = creditAccountShortCode; summaryUnit.Account = creditAccount.Substring(0, 6); summaryUnit.FundCode = creditAccount.Substring(6, 5); summaryUnit.DeptID = creditAccount.Substring(11, 6); summaryUnit.ProgramCode = creditAccount.Substring(17, 5); summaryUnit.ClassName = creditAccount.Substring(22, 5); summaryUnit.ProjectGrant = creditAccount.Substring(27, 7); summaryUnit.InvoiceDate = EndPeriod.AddMonths(-1).ToString("yyyy/MM/dd"); summaryUnit.Uniqname = ReportSettings.FinancialManagerUserName; summaryUnit.DepartmentalReferenceNumber = depRefNum; summaryUnit.ItemDescription = ReportSettings.FinancialManagerUserName; summaryUnit.MerchandiseAmount = Math.Round(-fTotal, 2); summaryUnit.CreditAccount = creditAccount; //Clean things up manually might help performance in general dtRoomDB.Clear(); dtClient.Clear(); dtAccount.Clear(); }
protected void btnReport_Click(object sender, EventArgs e) { DateTime period = pp1.SelectedPeriod; int totalMonths = Convert.ToInt32(txtNumMonths.Text); int currentBillingTypeId = BillingTypes.Other; decimal totalRoomSum = 0; decimal totalRoomPerUseSum = 0; decimal totalToolSum = 0; decimal finalRoomSum = 0; decimal finalToolSum = 0; decimal finalFutureRoomSum = 0; decimal finalFutureToolSum = 0; //2008-11-04 For non Academics, we need to reduce the hour rate from current $77 to about $15 dollar, so the mutiplier ratio here is 15/77 = 0.19 decimal nonAcFutureRoomMultiplier = 0.19M; //WTF IS THIS???? DataTable dtAllUsers = new DataTable(); dtAllUsers.Columns.Add("Name", typeof(string)); dtAllUsers.Columns.Add("CurrentPayment", typeof(double)); dtAllUsers.Columns.Add("FuturePayment", typeof(double)); //we need a table that contains all the accounts associated with this manager //people like Ning belongs to more than 1 org, so we have to filter out the accounts that are not in this particular org DataTable dtAccount = ClientDA.GetAllAccountsByClientOrgID(Convert.ToInt32(ddlManager.SelectedValue)); int[] billingTypesChargedByToolUsage = { BillingTypes.ExtAc_Hour, BillingTypes.Int_Hour, BillingTypes.NonAc_Hour, BillingTypes.ExtAc_Tools, BillingTypes.Int_Tools, BillingTypes.NonAc_Tools }; int[] specialBillingTypesForSomeUnknownReason = { BillingTypes.NonAc, BillingTypes.NonAc_Hour, BillingTypes.NonAc_Tools }; if (ddlUser.SelectedValue == "0") { //We have to caluclate ALL users belong to this manager foreach (ListItem userItem in ddlUser.Items) { if (userItem.Value != "0") //we must exclude the "All" listItem { DataRow ndr = dtAllUsers.NewRow(); DateTime p = period; for (int i = 1; i <= totalMonths; i++) { totalRoomSum = 0; totalRoomPerUseSum = 0; totalToolSum = 0; currentBillingTypeId = CalculateMonthlyFeePerUser(Convert.ToInt32(userItem.Value), p, currentBillingTypeId, dtAccount, ref totalRoomSum, ref totalRoomPerUseSum, ref totalToolSum); finalRoomSum += totalRoomSum; //addl tool cost for those users who are charged by tools usage now (hours and tools) if (billingTypesChargedByToolUsage.Contains(currentBillingTypeId)) { finalToolSum += totalToolSum; } if (specialBillingTypesForSomeUnknownReason.Contains(currentBillingTypeId)) { //2008-11-04 For non Academics, we need to reduce the hour rate totalRoomPerUseSum *= nonAcFutureRoomMultiplier; } finalFutureRoomSum += totalRoomPerUseSum; finalFutureToolSum += totalToolSum; ndr["Name"] = userItem.Text; //for per usage types (such as xxx_hour or xxx_tool, we need to include the tool fee for current payment int[] billingTypesForPerUsage = { BillingTypes.ExtAc_Hour, BillingTypes.Int_Hour, BillingTypes.NonAc_Hour, BillingTypes.ExtAc_Tools, BillingTypes.Int_Tools, BillingTypes.NonAc_Tools }; if (billingTypesForPerUsage.Contains(currentBillingTypeId)) { ndr["CurrentPayment"] = Math.Round(totalRoomSum, 2) + Math.Round(totalToolSum, 2); } else { //the users are montly flat room billing type ndr["CurrentPayment"] = Math.Round(totalRoomSum, 2); } ndr["FuturePayment"] = Math.Round((totalRoomPerUseSum + totalToolSum), 2); //If there is no usage for this account, then don't show it if (ndr.Field <double>("CurrentPayment") != 0 && ndr.Field <double>("FuturePayment") != 0) { dtAllUsers.Rows.Add(ndr); } //remember to add one month at the very end p = p.AddMonths(1); } } } } else { DateTime p = period; for (int i = 1; i <= totalMonths; i++) { totalRoomSum = 0; totalRoomPerUseSum = 0; totalToolSum = 0; currentBillingTypeId = CalculateMonthlyFeePerUser(Convert.ToInt32(ddlUser.SelectedValue), p, currentBillingTypeId, dtAccount, ref totalRoomSum, ref totalRoomPerUseSum, ref totalToolSum); finalRoomSum += totalRoomSum; //addl tool cost for those users who are charged by tools usage now (hours and tools) if (billingTypesChargedByToolUsage.Contains(currentBillingTypeId)) { finalToolSum += totalToolSum; } if (specialBillingTypesForSomeUnknownReason.Contains(currentBillingTypeId)) { //2008-11-04 For non Academics, we need to reduce the hour rate totalRoomPerUseSum *= nonAcFutureRoomMultiplier; } finalFutureRoomSum += totalRoomPerUseSum; finalFutureToolSum += totalToolSum; //remember to add one month at the very end p = p.AddMonths(1); } } lblRoomCost.Text = string.Format("Current Room Cost (plus entry fee): {0:$#,##0.00}", finalRoomSum); lblToolCost.Text = string.Format("Current Tool Cost (if applies): {0:$#,##0.00}", finalToolSum); lblCurrentRoomCost.Text = string.Format("Current payment: {0:$#,##0.00}", finalRoomSum + finalToolSum); lblPerUseRoomCost.Text = string.Format("Future Per Usage Room Cost: {0:$#,##0.00}", finalFutureRoomSum); lblPerUseToolCost.Text = string.Format("Future Per Usage Tool Cost: {0:$#,##0.00}", finalFutureToolSum); lblRealCost.Text = string.Format("Real Cost (Room + Tool): {0:$#,##0.00}", finalFutureRoomSum + finalFutureToolSum); gvAllUsers.DataSource = dtAllUsers; gvAllUsers.DataBind(); }
public static DataTable GetRemoteClientByDate(int year, int month) { DateTime sDate = new DateTime(year, month, 1); return(ClientDA.GetRemoteUser(sDate, sDate.AddMonths(1))); }
public static DataTable GetStaff(int year, int month) { DateTime sDate = new DateTime(year, month, 1); return(ClientDA.GetStaff(sDate, sDate.AddMonths(1))); }
private void buttonList_Click(object sender, EventArgs e) { listViewClient.Items.Clear(); ClientDA.ListClients(listViewClient); }
public static QueryResult <Client> QueryAllClientList(ClientFilter filter) { return(ClientDA.QueryAllClientList(filter)); }
/// <summary> /// 删除Client信息 /// </summary> public static void DeleteClient(int sysNo) { ClientDA.DeleteClient(sysNo); }
/// <summary> /// 更新Client信息 /// </summary> public static void UpdateClient(Client entity) { CheckClient(entity, false); ClientDA.UpdateClient(entity); }
private void buttonDeleteBook_Click(object sender, EventArgs e) { ClientDA.Delete(Convert.ToInt32(textBoxClientId.Text)); MessageBox.Show("Client has been deleted successfully from the database", "Confirmation"); }
public static Client LoadClientByAppCustomerID(string appCustomerID) { return(ClientDA.LoadClientByAppCustomerID(appCustomerID)); }