public async Task <IActionResult> Create([Bind("id,ReferenceNo,SlipDate,ProviderTradingProfileID,TxnID,AccountBankAccountID,SenderID,SlipAmount,ActualAmount,DateTimeModified,DateTimeAdded")] Slip slip) { if (ModelState.IsValid) { slip.DateTimeModified = Utility.GetLocalDateTime(); slip.DateTimeAdded = Utility.GetLocalDateTime(); _context.Add(slip); await _context.SaveChangesAsync(); /////////////////////////////////////////////////////////////////////////////////////////////////////////// //update AccountTxn if (slip.ActualAmount != null && slip.ActualAmount > 0) { AccountTxn accountTxn = new AccountTxn(); accountTxn.Type = "S"; accountTxn.ReferenceID = slip.id; accountTxn.AccountBankAccountID = slip.AccountBankAccountID; accountTxn.AmountCredit = slip.ActualAmount; accountTxn.DateTimeModified = Utility.GetLocalDateTime(); accountTxn.DateTimeAdded = Utility.GetLocalDateTime(); _context.Add(accountTxn); await _context.SaveChangesAsync(); } ///////////////////////////////////////////////////////////////////////////// return(RedirectToAction(nameof(Index))); } ViewBag.ProviderTradingProfile = new SelectList(_context.TxnView.ToList().Where(x => x.Type != "L").GroupBy(x => x.ProviderTradingProfileID).Select(x => x.First()).OrderBy(x => x.ProviderTradingProfileName), "ProviderTradingProfileID", "ProviderTradingProfileName"); ViewBag.AccountBankAccount = new SelectList(_context.AccountBankAccount.OrderBy(x => x.AccountName).ToList(), "id", "AccountName"); return(View(slip)); }
internal static Slip MapRowToSlipObject(DataRow row) { var empSlip = new Slip(); empSlip.EmpNumber = row[0].ToString(); empSlip.Month = row[1].ToString(); empSlip.BalanceBfDebit = row[2].ToString(); empSlip.BalanceBfCredit = row[3].ToString(); empSlip.SalaryThisMonthDebit = row[4].ToString(); empSlip.SalaryThisMonthCredit = row[5].ToString(); empSlip.OvertimeDebit = row[6].ToString(); empSlip.OvertimeCredit = row[7].ToString(); empSlip.TicketCompensationDebit = row[8].ToString(); empSlip.TicketCompensationCredit = row[9].ToString(); empSlip.HouseAllowanceDebit = row[10].ToString(); empSlip.HouseAllowanceCredit = row[11].ToString(); empSlip.VacationAllowanceDebit = row[12].ToString(); empSlip.VacationAllowanceCredit = row[13].ToString(); empSlip.ServiceAwardDebit = row[14].ToString(); empSlip.ServiceAwardCredit = row[15].ToString(); empSlip.CarAllowanceDebit = row[16].ToString(); empSlip.CarAllowanceCredit = row[17].ToString(); empSlip.MiscDebit = row[18].ToString(); empSlip.MiscCredit = row[19].ToString(); empSlip.CashOtherAdvanceDebit = row[20].ToString(); empSlip.CashOtherAdvanceCredit = row[21].ToString(); empSlip.TransfersDebit = row[22].ToString(); empSlip.TransfersCredit = row[23].ToString(); empSlip.TotalMovementsDebit = row[24].ToString(); empSlip.TotalMovementsCredit = row[25].ToString(); empSlip.OutstandingBalanceDebit = row[26].ToString(); empSlip.OutstandingBalanceCredit = row[27].ToString(); return(empSlip); }
Dock dock; // dock object used to get dock table data // fill the list of slips, slipIDsBooked and leases // with entity, populate the drop down, and fill the data for first id by default protected void Page_Load(object sender, EventArgs e) { listSlips = marina.Slips.ToList(); listLeases = marina.Leases.ToList(); listDocks = marina.Docks.ToList(); foreach (Lease l in listLeases) { slipIDsBooked.Add(l.SlipID); } PopulateSlipIDDropDown(); // get the first slip ID item and fill the text boxes with data dock = marina.Docks.Find(1); slippy = marina.Slips.Find(1); txtName.Text = dock.Name.ToString(); txtWidth.Text = slippy.Width.ToString() + " feet"; txtLength.Text = slippy.Length.ToString() + " feet"; water.Checked = dock.WaterService; electric.Checked = dock.ElectricalService; txtDockName2.Text = dock.Name.ToString(); water2.Checked = dock.WaterService; electric2.Checked = dock.ElectricalService; }
public static IList <Slip> GetAllSlips() { DataGateWay access = new DataGateWay(connectionName); IList <Slip> Slips = new List <Slip>(); string sql = @"use InlandMarina SELECT * FROM Slip"; Slip slip = null; try { using (var reader = access.ExecuteQuery(sql, null, CommandType.Text)) { while (reader.Read()) { slip = new Slip() { ID = reader.GetInt32(reader.GetOrdinal("ID")), Width = reader.GetInt32(reader.GetOrdinal("Width")), Length = reader.GetInt32(reader.GetOrdinal("Length")), DockID = reader.GetInt32(reader.GetOrdinal("DockID")) }; Slips.Add(slip); } } } catch (Exception ex) { throw new Exception("Error retrieving data from database !", ex); } return(Slips); }
public static List <Slip> GetSlips(int ID) { SqlConnection connection = MarinaDB.GetConnection(); List <Slip> results = new List <Slip>(); try { string sql = "SELECT ID, Width, Length, DockID FROM Slip" + " WHERE DockID=" + ID; SqlCommand command = new SqlCommand(sql, connection); SqlDataReader reader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection); while (reader.Read()) { Slip s = new Slip(); s.ID = Convert.ToInt32(reader["ID"].ToString()); s.Width = Convert.ToInt32(reader["Width"].ToString()); s.Length = Convert.ToInt32(reader["Length"].ToString()); s.DockID = Convert.ToInt32(reader["DockID"].ToString()); results.Add(s); } } catch { } finally { connection.Close(); } return(results); }
private void CloseBillWhenIsPaid(Slip slip, Bill bill) { if (BillIsPaid(bill, slip)) { bill.Close(); billBook.Update(bill); } }
public void Pay(Bill bill) { var slip = new Slip(bill.Id); slipBook.Add(slip); CloseBillWhenIsPaid(slip, bill); }
public void AddPayments(Slip slip) { var bill = billBook.Get(slip.Id); slipBook.Update(slip); CloseBillWhenIsPaid(slip, bill); }
public void DeleteSlip(Slip slip) { if ((slip.EntityState == EntityState.Detached)) { this.ObjectContext.Slips.Attach(slip); } this.ObjectContext.Slips.DeleteObject(slip); }
static void Main() { /* Create an object of class "TotalSales", providing "5" and "3" as parameters for the class's constructor. Using them * the constructor is creating an object, which private two-dimentional field "sales[]" would have 5 rows with 3 columns. */ TotalSales salesTable = new TotalSales(5, 3); // Print a welcome message. Console.WriteLine("The app calculates total sales for 3 salespersons and 5 product types.\n" + "In order to fill the resulting summary sales table, you need to provide a list of slips,\n" + "where every slip contains: number of a salesperson, numeber of a product\n" + "and total dollar value of the product sold that day by the salesperson."); // Declare a local variable "toContinue" to use it in while loop continuation test. bool toContinue = true; // While user answers "y" for the "ToContinue()" method's question. while (toContinue) { Console.WriteLine(); Console.WriteLine("Entering data for the next slip."); Console.Write("Please enter a salesperson number: "); /* Create an object of class "Slip", providing "5" and "3" as parameters for the class's constructor. Using them * the constructor is creating a "slip" object which wouldn't allow to set product or salesperson greater than these values. * Notice that new object is created during every iteration of while loop. * Old objects are deleted from memory by the C# garbage collector. * https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/ */ Slip slip = new Slip(5, 3); // Write the next number of a salesperson to "SalesmanNumber" - the property of "slip" object. slip.SalesmanNumber = int.Parse(Console.ReadLine()); Console.Write("Please enter a product number: "); // Write the next number of a product to "ProductNumber" - the property of "slip" object. slip.ProductNumber = int.Parse(Console.ReadLine()); Console.Write("Please enter the total dollar value of the product sold that day: "); // Write the next dollar value to "DollarValue" - the property of "slip" object. slip.DollarValue = decimal.Parse(Console.ReadLine()); /* Call a "salesTable" class's method "AddSalesDataFromSlip()" providing a "slip" object as a parameter. * The method would add data stored in the object to a "sales" field stored in its class. */ salesTable.AddSalesDataFromSlip(slip); // Ask user whether he/she wants to enter data for the next slip. toContinue = ToContinue(); } Console.WriteLine(); Console.WriteLine("The total sales table:"); // Call a "salesTable" class's method "PrintTotalSalesTable()" which prints a resulting table. salesTable.PrintTotalSalesTable(); Console.WriteLine(); Console.WriteLine(); Console.Write("Press any key to exit."); /* The method "ReadKey()" of class "Console" is similar to "ReadLine()" method, but reads not a string of characters, * followed by "Enter" key, but in contrast reads a single character pressed by a user. * It is useful when you need a console window to left opened after an application finishes its work. */ Console.ReadKey(); }
private void SendEmpEmail(EmployeeInfo emp, Slip slip) { var empPdfPath = @"c:\salarySlipsPdfs\" + emp.EmpNumber + ".pdf"; if (File.Exists(empPdfPath)) { Sender.Send(slip.Month, empPdfPath); var mailMessage = new MailMessage() { Body = emailTemplate.Replace("[FullName]", emp.Name).Replace("[month]", slip.Month), BodyEncoding = Encoding.UTF8, From = new MailAddress(account), IsBodyHtml = true, Priority = MailPriority.High, Subject = "Norconsult Employee Monthly Salary Slip" }; mailMessage.To.Add(new MailAddress(emp.Email)); mailMessage.Attachments.Add(new Attachment(empPdfPath, MediaTypeNames.Application.Octet)); try { var smpt = new SmtpClient() { EnableSsl = enableSSL, UseDefaultCredentials = false, Credentials = new NetworkCredential(account, password, "ntww.com"), Host = smtpServer, Port = port }; smpt.Send(mailMessage); successEmails.Add(emp.Email); //PostAttachmentAPI(emp, slip); } catch (SmtpFailedRecipientsException recipientException) { errors.Add(new EmailError() { Email = recipientException.FailedRecipient, ErrorDate = DateTime.Now, ErrorMessage = recipientException.Message }); } catch (SmtpException smtpException) { errors.Add(new EmailError() { Email = emp.Email, ErrorDate = DateTime.Now, ErrorMessage = smtpException.Message }); } catch (Exception ex) { errors.Add(new EmailError() { Email = emp.Email, ErrorDate = DateTime.Now, ErrorMessage = ex.Message }); } } }
// Public method "AddSalesDataFromSlip()" that takes an object of class "Slip" as an argument and returns no value. public void AddSalesDataFromSlip(Slip slip) { /* Add dollar value taken from a "slip" to a cell with appropriate index numbers of a product and a salesperson. * Indexes in arrays in C# starts from 0, but in everyday life people usually start counting from 1. * To avoid space waisting we store salesperson with number 1 in a cell with index number 0, salesperson with number 2 in cell * with index number 1 and so on. It is related to both rows and columns and both product numbers and salespersons numbers. * And as soon as object of clsss "Slip" stores real numbers of a salesperson and a product, we need to decrements them * by 1 before using as indexes of the array. */ sales[(slip.ProductNumber - 1), (slip.SalesmanNumber - 1)] += slip.DollarValue; }
// a method to get a list of available slips for a selected docks from the database: public static List <Slip> GetSlips(int Id) { // make an empty list of slip-dock List <Slip> SlipsList = new List <Slip>(); // make an empty slip-dock object Slip SL = new Slip(); // get connected to the database SqlConnection con = InlandMarinaScriptDB.GetConnection(); // creating the proper sql query to extract data from MS SQL server string Query = "SELECT ID, Width, Length, DockID FROM Slip WHERE DockID = @DockID"; // creating the proper command to run the query SqlCommand comm = new SqlCommand(Query, con); comm.Parameters.AddWithValue("@DockID", Id); // try to run the command try { // opening the connection con.Open(); // creating a sql data reader and run it to read the data from the database SqlDataReader dr = comm.ExecuteReader(); // read line by line as much as there is something to read while (dr.Read()) { // for each line of the returned rows of data from database, //assign the column values to the properties of a new slip-dock object SL = new Slip(); SL.SlipId = (int)dr["ID"]; SL.Width = (int)dr["Width"]; SL.Length = (int)dr["Length"]; SL.DockId = (int)dr["DockID"]; // adding the new object to the list of objects SlipsList.Add(SL); } dr.Close(); // closing the data reader } catch (Exception ex) { throw ex; } finally { con.Close(); } return(SlipsList); }
//public IQueryable<Slip> GetSlipsByCompanyIDTradingDateForAdd(global::System.Guid companyID, DateTime tradingDate) //{ // return new EnumerableQuery<Slip>(new List<Slip> { new Slip { // CompanyID = companyID, // SlipID = global::System.Guid.NewGuid(), // TradingDate = tradingDate // } }); //} public void InsertSlip(Slip slip) { if ((slip.EntityState != EntityState.Detached)) { this.ObjectContext.ObjectStateManager.ChangeObjectState(slip, EntityState.Added); } else { this.ObjectContext.Slips.AddObject(slip); } }
/// <summary> /// creates Slip object /// </summary> /// <returns>Slip object</returns> private Slip buildSelectedSlip() { Slip selectedSlip = new Slip(); selectedSlip.ID = Convert.ToInt32(uxAvailSlipSortedByDock1.SelectedRow.Cells[1].Text); selectedSlip.Width = Convert.ToInt32(uxAvailSlipSortedByDock1.SelectedRow.Cells[2].Text); selectedSlip.Length = Convert.ToInt32(uxAvailSlipSortedByDock1.SelectedRow.Cells[3].Text); selectedSlip.DockID = Convert.ToInt32(uxAvailSlipSortedByDock1.SelectedRow.Cells[4].Text); return(selectedSlip); }
/// <summary> /// Performs a insert operation to the lease table in the DB with the provided slip /// </summary> /// <param name="slip"></param> private void InsertNewLeaseDB(Slip slip) { //get the customer id for the logged in user from the DB Customer customer = CustomerDB.GetCustomer(Session["UserName"].ToString()); // e.Row.Cells[colIndex].BackColor = Color.FromName("#ffeb9c"); LeaseDB.InsertLease(slip, customer); //refresh gridviews RefreshDataBindings(); }
/// <summary> /// Event handler for when user clicks on "Lease" /// </summary> /// <param name="sender">reference to the control/object that raises the event</param> /// <param name="e">event data</param> protected void uxAvailSlipSortedByDock1_SelectedIndexChanged1(object sender, EventArgs e) { //build selected slip by function Slip selectedSlip = buildSelectedSlip(); //add selected slip to database by a function addSelectedSlipToDatabase(selectedSlip); //add to new lease to customer by a function addNewLease(selectedSlip.ID); //refreshs page Response.Redirect(Request.RawUrl.ToString()); }
public async Task <SlipModel> CreateSlip(CreateSlipModel model) { var newSlip = new Slip { }; var result = Slips.Add(newSlip); await SaveChangesAsync(); return(new SlipModel(result.Entity)); }
public Boolean Add(Slip tSlip) { if (null == tSlip) { return(false); } lock (((ICollection)m_SlipList).SyncRoot) { m_SlipList.Add(tSlip); } return(true); }
public void ClaimInsuredThreeSlipsRePrintOne_GetListOfSlip_TwoOfPrintedSlips() { //arrange string formName = " B328/06/2017 10:16(1)| A28/06/2017 10:16(1)| B328/06/2017 10:20(2)|"; var slip = new Slip(); var printType = PrintType.ClaimInsured; //act var result = slip.GetPrintedSlip(printType, formName); //assert Assert.Equal(new string[] { "A28/06/2017 10:16(1)", "B328/06/2017 10:20(2)" }, result); }
// GET: Slip/Create public IActionResult Create() { ViewBag.ProviderTradingProfile = new SelectList(_context.TxnView.ToList().Where(x => x.Type != "L" && x.ProviderTradingProfileID != null).GroupBy(x => x.ProviderTradingProfileID).Select(x => x.First()).OrderBy(x => x.ProviderTradingProfileName), "ProviderTradingProfileID", "ProviderTradingProfileName"); //ViewBag.Txn = new SelectList(_context.Txn.ToList(), "id", "ReferenceNo"); ViewBag.AccountBankAccount = new SelectList(_context.AccountBankAccount.OrderBy(x => x.AccountName).ToList(), "id", "AccountName"); //ViewBag.Sender = new SelectList(_context.Sender.ToList(), "id", "SenderName"); Slip slip = new Slip(); slip.ReferenceNo = "S" + Utility.GetLocalDateTime().ToString("yyyyMMddHHmmss"); slip.SlipDate = Utility.GetLocalDateTime().Date; return(View(slip)); }
// when a selected index is changed get the slippy object for the slip id chosen and display protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { temp = DropDownList1.SelectedItem.ToString(); slippy = marina.Slips.Find(Convert.ToInt32(temp)); dock = marina.Docks.Find(slippy.DockID); txtName.Text = dock.Name.ToString(); txtDockName2.Text = dock.Name.ToString(); txtWidth.Text = slippy.Width.ToString() + " feet"; txtLength.Text = slippy.Length.ToString() + " feet"; water.Checked = dock.WaterService; electric.Checked = dock.ElectricalService; water2.Checked = dock.WaterService; electric2.Checked = dock.ElectricalService; }
public Slip Build(Order order, SlipType type) { _slipFabric = GetFabric(order); switch (type) { case SlipType.Standard: return(Slip.Create(_slipFabric.Standard(order))); case SlipType.Crash: return(Slip.Create(_slipFabric.Crash(order))); default: throw new NotImplementedException(); } }
private void GetAddSlip(global::System.Guid companyID, DateTime tradingDate) { //this.NowLoading<Slip>( // this.Context.GetSlipsByCompanyIDTradingDateForAddQuery(companyID, tradingDate), // ent => // { // this.Slip = ent.FirstOrDefault(); // this.Context.Slips.Add(this.Slip); // } //); this.Slip = Slip.CreateAddNewSlip(companyID, tradingDate); this.Context.Slips.Add(this.Slip); }
public void Remove(Slip tSlip) { if (null == tSlip) { return; } lock (((ICollection)m_SlipList).SyncRoot) { Int32 tIndex = m_SlipList.IndexOf(tSlip); if (-1 != tIndex) { m_SlipList.Remove(m_SlipList[tIndex]); } } }
/// <summary> /// Event occurs when a slip is leased /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvSlips_SelectedIndexChanged(object sender, EventArgs e) { GridView gv = (GridView)sender; //get the selected slip data from the gridview Slip slip = new Slip() { ID = Convert.ToInt32(gv.SelectedRow.Cells[1].Text), Width = Convert.ToInt32(gv.SelectedRow.Cells[2].Text), Length = Convert.ToInt32(gv.SelectedRow.Cells[3].Text), DockID = Convert.ToInt32(gv.SelectedRow.Cells[4].Text), }; //insert new lease into DB InsertNewLeaseDB(slip); }
public bool Print(Order order, SlipType type, out string imageFile) { try { Slip slip = Build(order, type); Image image = HtmlRender.RenderToImage(slip.Data, new Size(250, 800), new Size(270, 800), Color.White); string filename = order.Number; int index = 0; string postfix = string.Empty; while (File.Exists(_slipSettings.SlipImageStorage + @$ "\{filename}.html")) { index++; filename = $"{order.Number}_{index}"; } string file = _slipSettings.SlipImageStorage + @$ "\{filename}.html";
static void checkEquality(Slip aSlip, Slip anotherSlip) { string temp; bool status = aSlip.Equals(anotherSlip); temp = string.Format("Comparing Slips: "); if (aSlip.Equals(anotherSlip) && anotherSlip.Equals(aSlip)) { temp += string.Format("Are Slips Equal? : {0} >>", status); temp += string.Format(" Hasscode: {0} and {1}\n", aSlip.GetHashCode(), anotherSlip.GetHashCode()); } else { temp += string.Format("Are Slips Equal? : {0}\n", status); } Console.WriteLine(temp); }
public async Task <SlipModel> UpdateSlip(long id, UpdateSlipModel model) { var slip = await Slips.FindAsync(id); if (slip != null) { var update = new Slip { Id = id }; var result = Slips.Update(update); await SaveChangesAsync(); return(new SlipModel(result.Entity)); } return(null); }
protected void uxSlip_SelectedIndexChanged(object sender, EventArgs e) { if (SlipSelect != null) { var ID = Convert.ToInt32(uxSlip.SelectedValue); Slip sp = MarinaManager.FindSlip(ID); Slip = sp; var arg = new SlipEventArgs { ID = sp.ID, Width = sp.Width, Length = sp.Length, DockID = sp.DockID }; SlipSelect.Invoke(this, arg); } }