Ejemplo n.º 1
0
        private string GetConsignmentResultDetails(ConsignmentResult result)
        {
            if (result == null)
            {
                return("");
            }

            stringBuilder.Clear();
            stringBuilder.AppendLine(string.Format("{0,-20} {1}", "Consignor Id",
                                                   result.Consignor.ConsignorId));
            stringBuilder.AppendLine(string.Format("{0,-20} {1}", "Consignor Name",
                                                   result.Consignor.ConsignorName.Trim()));
            stringBuilder.AppendLine(string.Format("{0,-20} {1}", "Consignor DOB",
                                                   ((DateTime)result.Consignor.ConsignorDOB).ToString("dd MMMM yyyy")));
            stringBuilder.AppendLine(string.Format("{0,-20} {1}", "Consignor Phone",
                                                   result.Consignor.ConsignorPhone.Trim()));
            stringBuilder.AppendLine(string.Format("{0,-20} {1}", "Consignor Email",
                                                   result.Consignor.ConsignorEmail.Trim()));
            stringBuilder.AppendLine(string.Format("{0,-20} {1}", "Consignor Period",
                                                   ConsignmentStoreBusinessLogic.GetConsignmentPeriodFromInt(result.ConsignmentPeriod)));
            stringBuilder.AppendLine(string.Format("{0,-20} {1:n0}", "Returned Items",
                                                   result.NumberOfReturnedItems));
            stringBuilder.AppendLine(string.Format("{0,-20} {1:c}", "Value Items",
                                                   result.TotalValueOfReturnedItems));
            stringBuilder.AppendLine(string.Format("{0,-20} {1:c}", "Consignment Result",
                                                   result.TotalValueReceivedByConsignor));

            return(stringBuilder.ToString());
        }
Ejemplo n.º 2
0
        private void ReturnResult(object sender, EventArgs e)
        {
            if (consignmentResult == null)
            {
                return;//no result is selected
            }
            //update consignment result table
            consignmentResult.ReturnedDate = DateTime.Now;
            consignmentResult.ReturnedBy   = ConsignmentStoreBusinessLogic.loggedInEmployee.EmployeeId;

            //update expenses table
            context.Expenses.Add(new Expens
            {//set ConsignmentResult expense date =  ReturnedDate
                Date     = (DateTime)consignmentResult.ReturnedDate,
                Amount   = consignmentResult.TotalValueReceivedByConsignor,
                Category = "ConsignmentResult"
            });

            context.SaveChanges();//save to database

            consignmentResult = null;

            //refresh view
            dataGridViewConsignmentResults.DataSource = context.ConsignmentResults.Where(result => !result.ReturnedDate.HasValue &&
                                                                                         !result.ReturnedBy.HasValue).ToList();
            textBoxResultDetail.Text = GetConsignmentResultDetails(consignmentResult);
        }
Ejemplo n.º 3
0
        private void DisplayDetailOfConsignmentResult(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)//not header row
            {
                int consignorId       = int.Parse(dataGridViewConsignmentResults.Rows[e.RowIndex].Cells[0].Value.ToString());
                int consignmentPeriod = int.Parse(dataGridViewConsignmentResults.Rows[e.RowIndex].Cells[1].Value.ToString());

                //get the consignment result
                consignmentResult = context.ConsignmentResults.Local.Single(result =>
                                                                            result.ConsignmentPeriod == consignmentPeriod &&
                                                                            result.ConsignorId == consignorId);

                //display it
                textBoxResultDetail.Text = GetConsignmentResultDetails(consignmentResult);
            }
        }