Beispiel #1
0
 private void SelectedDriverCompobox(int Id)
 {
     driverComboBox.ValueMember   = "Id";
     driverComboBox.DisplayMember = "FullName";
     driverComboBox.DataSource    = DriverBl.GetList();
     driverComboBox.SelectedValue = Id;
 }
Beispiel #2
0
        public static List <MasterReport> GetList()
        {
            List <MasterReport> items = new List <MasterReport>();



            foreach (var item in TripBl.GetList())
            {
                MasterReport reportData = new MasterReport();
                Refill       r          = new RefillBl().GetById(item.RefillId);
                Vehicle      v          = new VehicleBl().GetById(item.VehicleId);
                Driver       d          = new DriverBl().GetById(item.DriverId);

                string closed = "";

                reportData.DateTimeStart    = string.Format("{0}", item.DateTimeStart.ToString("dd/MM/yy,hh:mm tt"));
                reportData.DateTimeEnd      = string.Format("{0}", item.DateTimeEnd.ToString("dd/MM/yy,hh:mm tt"));
                reportData.DriverName       = d.FullName;
                reportData.DriverId         = d.Id;
                reportData.VehicleName      = string.Format("{0}({1})", v.Name, v.RegistrationNumber);
                reportData.VehicleId        = v.Id;
                reportData.Refill           = string.Format("Refill No: {5}\nDate: {0}\nAmount: ${1}\nLiterage: {2}L\nPerfo': {3}km/l\nStatus: {4}", r.DateAndTime.ToString("dd/MM/yy "), r.Amount, r.Litreage, (RefillBl.TotalMileage(r.Id) / (decimal)r.Litreage).ToString("N2"), closed = r.Closed ? "Closed" : "Open", r.Id);
                reportData.RefillId         = r.Id;
                reportData.MileageStart     = item.MileageStart;
                reportData.MileageEnd       = item.MileageEnd;
                reportData.MileageTravelled = (item.MileageEnd - item.MileageStart);
                reportData.TripDetails      = item.TripDetails;
                reportData.ExpenseAccount   = item.ExpenseAccount;
                reportData.Cost             = (reportData.MileageTravelled / RefillBl.TotalMileage(r.Id)) * r.Amount;

                items.Add(reportData);
            }

            return(items);
        }
Beispiel #3
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            if (dataGridView.SelectedCells.Count > 0)
            {
                int selectedrowindex = dataGridView.SelectedCells[0].RowIndex;

                DataGridViewRow selectedRow = dataGridView.Rows[selectedrowindex];

                Id = int.Parse(Convert.ToString(selectedRow.Cells["Id"].Value));

                if (MessageBox.Show(String.Format("Are you sure to delete {0}?", Convert.ToString(selectedRow.Cells["FullName"].Value)), "Deleting...", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (TripBl.DriverInUse(Id))
                    {
                        MessageBox.Show("Driver is in use, can't be deleted.");
                        return;
                    }

                    DriverBl driverBl = new DriverBl();
                    driverBl.Delete(Id);
                    Id = 0;

                    RefreshGrid();
                }
            }
        }
 public Program()
 {
     employees = new EmployeeBL();
     drivers   = new DriverBl();
     Login     = new EmployeeLogin(employees);
     employee  = new EmployeeManagement(employees);
     driver    = new DriverManagement(drivers);
 }
Beispiel #5
0
        private void RefreshGrid()
        {
            _dataTable = Utility.ToDataTable(DriverBl.GetList());
            bindingSource.DataSource = _dataTable;
            dataGridView.DataSource  = bindingSource;
            dataGridView.Update();
            dataGridView.Refresh();

            dataGridView.Columns[0].Visible    = false;
            dataGridView.Columns[1].HeaderText = "Full Name";

            dataGridViewSearch.SetColumns(dataGridView.Columns);
        }
Beispiel #6
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            if (Valid())
            {
                DriverBl driverBl = new DriverBl();

                driverBl.Save(Id, fullNameTextBox.Text);

                fullNameTextBox.Text = "";
                Id = 0;

                RefreshGrid();
            }
        }
Beispiel #7
0
        public OperationResult InsertNewDriver(int userId, string name)
        {
            OperationResult or;

            try
            {
                or = new DriverBl().InsertNewDriver(userId, name);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(or);
        }
Beispiel #8
0
        public OperationResult GetDriverProfile(int id)
        {
            OperationResult or;

            try
            {
                or = new DriverBl().GetDriverProfile(id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(or);
        }
Beispiel #9
0
        public OperationResult GetDriverAttachments(int userId)
        {
            OperationResult or;

            try
            {
                or = new DriverBl().GetDriverAttachments(userId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(or);
        }
    public async Task <HttpResponseMessage> UpdateAttachement(long UserID, int key)
    {
        Dictionary <string, object> dict = new Dictionary <string, object>();

        try
        {
            var           httpRequest = HttpContext.Current.Request;
            List <string> pathes      = new List <string>();
            foreach (string file in httpRequest.Files)
            {
                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created);

                var postedFile = httpRequest.Files[file];

                if (postedFile != null && postedFile.ContentLength > 0)
                {
                    int            MaxContentLength      = 1024 * 1024 * 10; //Size = 1 MB
                    IList <string> AllowedFileExtensions = new List <string> {
                        ".jpg", ".gif", ".png"
                    };
                    var ext       = postedFile.FileName.Substring(postedFile.FileName.LastIndexOf('.'));
                    var extension = ext.ToLower();
                    if (!AllowedFileExtensions.Contains(extension))
                    {
                        var message = string.Format("Please Upload image of type .jpg,.gif,.png.");

                        dict.Add("error", message);
                        return(Request.CreateResponse(HttpStatusCode.BadRequest, dict));
                    }
                    else if (postedFile.ContentLength > MaxContentLength)
                    {
                        var message = string.Format("Please Upload a file upto 10 mb.");

                        dict.Add("error", message);
                        return(Request.CreateResponse(HttpStatusCode.BadRequest, dict));
                    }
                    else
                    {
                        //YourModelProperty.imageurl = userInfo.email_id + extension;
                        //  where you want to attach your imageurl

                        //if needed write the code to update the table

                        var filePath = HttpContext.Current.Server.MapPath("~/App_Data/" + key.ToString() + "_" + UserID.ToString() + postedFile.FileName.Replace(" ", string.Empty));
                        //Userimage myfolder name where i want to save my image
                        postedFile.SaveAs(filePath);
                        pathes.Add("http://api.shuhnaty.com/attachement/" + key.ToString() + "_" + UserID.ToString() + postedFile.FileName.Replace(" ", string.Empty));
                        var json = JsonConvert.SerializeObject(new
                        {
                            Files = pathes
                        });
                        OperationResult or;
                        try
                        {
                            or = new DriverBl().updateAttachments(UserID, key, "http://api.shuhnaty.com/attachement/" + key.ToString() + "_" + UserID.ToString() + postedFile.FileName.Replace(" ", string.Empty));
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                        //var message1 = string.Format("Image Updated Successfully.");
                        return(Request.CreateErrorResponse(HttpStatusCode.Created, json));
                    }
                }
            }

            var res = string.Format("Please Upload a image.");
            dict.Add("error", res);
            return(Request.CreateResponse(HttpStatusCode.NotFound, dict));
        }
        catch (Exception ex)
        {
            var res = string.Format(ex.StackTrace);
            dict.Add("error", res);
            return(Request.CreateResponse(HttpStatusCode.NotFound, dict));
        }
    }
Beispiel #11
0
 private void NewDriverCompobox()
 {
     driverNameComboBox.ValueMember   = "Id";
     driverNameComboBox.DisplayMember = "FullName";
     driverNameComboBox.DataSource    = DriverBl.GetList();
 }