Ejemplo n.º 1
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     errorProvider1.Clear();
     if (addUpdate == "add")
     {
         if (FillClass() == true)
         {
             curentFixTable.AddToAccess(curentFix);
             MessageBox.Show("תיקון התווסף בהצלחה");
             Car curentCar = new Car(curentFix.CarNumber);
             curentCar.Fix = false;
             CarTable curentTable = new CarTable();
             curentTable.UpdateToAccess(curentCar);
             lblSearch.Visible = false;
             txtSearch.Visible = false;
             btnSearsh.Visible = false;
         }
     }
     if (addUpdate == "update")
     {
         try
         {
             curentFix = new Fixs(Convert.ToInt32(txtSearch.Text));
             if (FillClass() == true)
             {
                 curentFixTable.AddToAccess(curentFix);
                 MessageBox.Show("תיקון התעדכן בהצלחה");
             }
         }
         catch
         {
             MessageBox.Show("לא נמצאו תיקונים מתאימים");
         }
     }
 }
Ejemplo n.º 2
0
 public void Clear()
 {
     C1                     = null;
     TextBox1.Text          = string.Empty;
     TextBox2.Text          = string.Empty;
     TextBox3.Text          = string.Empty;
     TextBox4.Text          = string.Empty;
     TextBox7.Text          = string.Empty;
     TextBox8.Text          = string.Empty;
     TextBox9.Text          = string.Empty;
     TextBox10.Text         = string.Empty;
     TextBox11.Text         = string.Empty;
     TextBox12.Text         = string.Empty;
     TextBox13.Text         = string.Empty;
     TextBox14.Text         = string.Empty;
     TextBox15.Text         = string.Empty;
     TextBox16.Text         = string.Empty;
     TextBox17.Text         = string.Empty;
     TextBox18.Text         = string.Empty;
     TextBox19.Text         = string.Empty;
     ComboBox1.SelectedItem = null;
     ComboBox2.SelectedItem = null;
     ComboBox3.SelectedItem = null;
     ComboBox4.SelectedItem = null;
     ComboBox5.SelectedItem = null;
     ComboBox6.SelectedItem = null;
     RadioButton1.Checked   = false;
     RadioButton2.Checked   = false;
 }
Ejemplo n.º 3
0
        public void insert()
        {
            List <CarTable> list = collection.FindAllAs <CarTable>().ToList();

            try
            {
                if (TextBox1.Text != string.Empty && TextBox2.Text != string.Empty && TextBox8.Text != string.Empty &&
                    TextBox9.Text != string.Empty && TextBox10.Text != string.Empty && TextBox11.Text != string.Empty &&
                    TextBox18.Text != string.Empty && ComboBox3.Text != string.Empty && ComboBox4.Text != string.Empty)
                {
                    C1 = new CarTable()
                    {
                        Car_company = TextBox1.Text,
                        Car_name    = TextBox2.Text,
                        Model       = TextBox8.Text,
                        Fuel_type   = ComboBox3.Text,
                        Price       = TextBox9.Text,
                        Colour      = TextBox10.Text,
                        Mileage     = TextBox11.Text,
                        Car_class   = ComboBox4.Text,
                        Image_path  = TextBox18.Text,
                    };
                    collection.Insert(C1);
                    MessageBox.Show("Car added successfully!");
                }
                else
                {
                    MessageBox.Show("Fields cannot be blank");
                }
            }
            catch (Exception ex) { MessageBox.Show("Error: " + ex + "\nPlease try again"); }
            Clear();
        }
Ejemplo n.º 4
0
 //פעולה בונה להזמנה
 public frmSearchCars(Form f2, DateTime fromd, int ob, DateTime tod, string longShort, double age, string lisence)
 {
     InitializeComponent();
     status            = "invite";
     lisenceC          = lisence;
     ageC              = age;
     f1                = f2;
     f1.Enabled        = false;
     curentBranch      = new Branch(ob);
     txtBranch.Text    = Convert.ToString(curentBranch.BranchName);
     btnReturn.Visible = true;
     lblWorker.Visible = true;
     lblClient.Visible = false;
     if (longShort == "long" || longShort == "short")
     {
         chbBranch.Checked = true;
     }
     else
     {
         chbBranch.Checked = false;
     }
     //מאפשר הצגת רכבים מכל הסניפים
     chbBranch.Visible = true;
     lblb.Visible      = true;
     txtBranch.Visible = true;
     //מילוי ה data table
     dtt = CarTable.GetTimesCars(branchs, true, dtpFrom.Value, dtpTo.Value);
     //המשתנה מלמעלה
     dgv = new DataView(dtt);
     //המשתנה מהטופס
     dgvTableCar.DataSource = dgv;
     dtpFrom.Value          = fromd.Date;
     dtpTo.Value            = tod.Date;
 }
Ejemplo n.º 5
0
 public NewErrorModel TableModify(CarTable carTable)
 {
     try
     {
         using (DDContext context = new DDContext())
         {
             carTable.FactKilometre = carTable.UseKilometres;
             Tasks tasks = context.Tasks.Where(t => t.TaskId.ToString() == carTable.TaskId && t.State == 0 && t.IsEnable == 1).FirstOrDefault();
             if (tasks.NodeId == 4)
             {
                 if (!string.IsNullOrEmpty(carTable.OccupyCarId) && !string.IsNullOrEmpty(carTable.FactKilometre))
                 {
                     CarTable carTableOld = context.CarTable.Find(int.Parse(carTable.OccupyCarId));
                     carTableOld.FactKilometre = (float.Parse(carTableOld.FactKilometre) - float.Parse(carTable.FactKilometre)).ToString();
                     context.Entry <CarTable>(carTableOld).State = System.Data.Entity.EntityState.Modified;
                     context.SaveChanges();
                 }
             }
             context.Entry <CarTable>(carTable).State = System.Data.Entity.EntityState.Modified;
             context.SaveChanges();
         }
         return(new NewErrorModel()
         {
             error = new Error(0, "修改成功!", "")
             {
             },
         });
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private void LoadAvailableCars(DateTime from, DateTime until, double hourRange)
        {
            AvailableCarsTable.Rows.Clear();
            RentalManager manager       = new RentalManager(new UnitOfWork(new RentalContext()));
            List <Car>    availableCars = manager.GetAvailableCars(from, until, hourRange);

            foreach (Car car in reservationCars)
            {
                if (!availableCars.Where(c => c.ID == car.ID).Any())
                {
                    AddTableRow(car.ID, car.Brand, car.Type, car.Color, (car.PriceFirst > 0) ? string.Format("€{0:0.00}", car.PriceFirst) : "N/A", (car.PriceFirst > 0) ? string.Format("€{0:0.00}", car.PriceFirst * 0.65) : "N/A", (car.PriceNight > 0) ? string.Format("€{0:0.00}", car.PriceNight) : "N/A", (car.PriceWedding > 0) ? string.Format("€{0:0.00}", car.PriceWedding) : "N/A", (car.PriceWellness > 0) ? string.Format("€{0:0.00}", car.PriceWellness) : "N/A");
                }
            }
            foreach (Car car in availableCars)
            {
                AddTableRow(car.ID, car.Brand, car.Type, car.Color, (car.PriceFirst > 0) ? string.Format("€{0:0.00}", car.PriceFirst) : "N/A", (car.PriceFirst > 0) ? string.Format("€{0:0.00}", car.PriceFirst * 0.65) : "N/A", (car.PriceNight > 0) ? string.Format("€{0:0.00}", car.PriceNight) : "N/A", (car.PriceWedding > 0) ? string.Format("€{0:0.00}", car.PriceWedding) : "N/A", (car.PriceWellness > 0) ? string.Format("€{0:0.00}", car.PriceWellness) : "N/A");
            }
            foreach (Car car in reservationCars)
            {
                int    index = GetDataGridIndex(car);
                object item  = CarTable.Items[index];
                CarTable.SelectedItems.Add(item);
                CarTable.ScrollIntoView(item);
            }
        }
Ejemplo n.º 7
0
 public object GetMonthReport(string StartTime, string EndTime, string UserId)
 {
     try
     {
         using (DDContext context = new DDContext())
         {
             //查询时间段内的数据
             List <CarTable> carTables = context.CarTable.Where(c => c.StartTime > DateTime.Parse(StartTime) &&
                                                                c.EndTime < DateTime.Parse(EndTime)).ToList();
             //更新实际行驶路程
             foreach (CarTable carTable in carTables)
             {
                 if (!string.IsNullOrEmpty(carTable.OccupyCarId))
                 {
                     CarTable catTb = context.CarTable.Find(carTable.OccupyCarId);
                     catTb.UseKilometres = (Int32.Parse(catTb.UseKilometres) - Int32.Parse(carTable.UseKilometres)).ToString();
                     context.Entry <CarTable>(catTb).State = System.Data.Entity.EntityState.Modified;
                     context.SaveChanges();
                 }
             }
             //计算公里数
             List <CarTable> carTableList = context.CarTable.ToList();
             List <Tasks>    tasksList    = FlowInfoServer.ReturnUnFinishedTaskId("13"); //公车任务流
             List <Tasks>    taskList     = new List <Tasks>();
             List <Car>      carList      = context.Car.ToList();
             foreach (Tasks tasks in tasksList)
             {
                 if (tasks.NodeId == 0)
                 {
                     taskList.Add(tasks);
                 }
             }
             var Quary = from t in taskList
                         join c in carTableList
                         on t.TaskId.ToString() equals c.TaskId
                         join cars in carList
                         on c.CarId equals cars.Id.ToString()
                         select new
             {
                 t.Dept,
                 t.ApplyMan,
                 c.StartTime,
                 c.EndTime,
                 cars.Name,
                 c.MainContent,
                 c.UseKilometres,
                 cars.UnitPricePerKilometre,
                 Price = Int32.Parse(c.UseKilometres) * cars.UnitPricePerKilometre
             };
             return(JsonConvert.SerializeObject(Quary));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 8
0
 static TableLocator()
 {
     furnitureTable  = new FurnitureTable("Table/Furniture");
     buffTable       = new BuffTable("Table/Buff");
     userDataTable   = new UserDataTable("Table/UserData");
     carTable        = new CarTable("Table/CarData");
     probsTable      = new ProbsTable("Table/Probs");
     mapDataTable    = new MapDataTable("Table/MapList");
     animalDataTable = new AnimalDataTable("Table/AnimalData");
 }
Ejemplo n.º 9
0
        private void metroGrid4_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            List <CarTable> list = metroGrid4.DataSource as List <CarTable>;

            C1             = list[e.RowIndex];
            TextBox17.Text = C1.Car_name;
        }
Ejemplo n.º 10
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     if (dtpFrom.Value > dtpTo.Value || dtpTo.Value <= DateTime.Now)
     {
         MessageBox.Show("הקש תאריכים חוקיים");
     }
     dtt = CarTable.GetTimesCars(branchs, chbBranch.Checked, dtpFrom.Value, dtpTo.Value);
     //המשתנה מלמעלה
     dgv = new DataView(dtt);
     //המשתנה מהטופס
     dgvTableCar.DataSource = dgv;
 }
Ejemplo n.º 11
0
        public ActionResult Create([Bind(Exclude = "id")] CarTable carToCreate)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            //_db AddToMovieSet(movieToCreate);
            _db.CarTable.Add(carToCreate);
            _db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 12
0
 public object TableSave(CarTable carTable)
 {
     try
     {
         using (DDContext context = new DDContext())
         {
             context.CarTable.Add(carTable);
             context.SaveChanges();
             Car car = context.Car.Find(Int32.Parse(carTable.CarId));
             //只保留五条最新数据
             if (!string.IsNullOrEmpty(car.UseTimes))
             {
                 if (car.UseTimes.Split(',').Length < 5)
                 {
                     car.UseTimes = car.UseTimes + "," + carTable.StartTime + "~" + carTable.EndTime;
                     car.UseMan   = car.UseMan + "," + carTable.DrivingMan;
                 }
                 else
                 {
                     car.UseTimes = car.UseTimes.Substring(car.UseTimes.IndexOf(','), car.UseTimes.Length - car.UseTimes.IndexOf(','));
                     car.UseMan   = car.UseMan.Substring(car.UseMan.IndexOf(','), car.UseMan.Length - car.UseMan.IndexOf(','));
                     car.UseTimes = car.UseTimes + "," + carTable.StartTime + "~" + carTable.EndTime;
                     car.UseMan   = car.UseMan + "," + carTable.DrivingMan;
                 }
             }
             else
             {
                 car.UseTimes = carTable.StartTime + "-" + carTable.EndTime;
                 car.UseMan   = carTable.DrivingMan;
             }
             car.OccupyCarId                = carTable.CarId;
             car.FinnalStartTime            = carTable.StartTime;
             car.FinnalEndTime              = carTable.EndTime;
             context.Entry <Car>(car).State = System.Data.Entity.EntityState.Modified;
             context.SaveChanges();
         }
         return(new ErrorModel()
         {
             errorCode = 0,
             errorMessage = "添加成功"
         });
     }
     catch (Exception ex)
     {
         return(new ErrorModel()
         {
             errorCode = 1,
             errorMessage = ex.Message
         });
     }
 }
Ejemplo n.º 13
0
        private void metroGrid2_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            List <CarTable> list = metroGrid2.DataSource as List <CarTable>;

            C1 = list[e.RowIndex];
            Form4 f = new Form4(C1.Image_path);

            f.Text = C1.Car_name;
            f.Show();
        }
Ejemplo n.º 14
0
 public frmSearchCars(Form f2, string st, int ob, string user)
 {
     InitializeComponent();
     branchs    = ob;
     f1         = f2;
     f1.Enabled = false;
     //להצגת רכבים בסניף זה
     if (st == "one" && user == "worker")
     {
         lblWorker.Visible = true;
         lblClient.Visible = false;
         chbBranch.Visible = true;
         lblb.Visible      = true;
         txtBranch.Visible = true;
         chbBranch.Checked = true;
     }
     //להצגת רכבים שנמצאים כרגע בסניף
     if (st == "one" && user == "client")
     {
         lblWorker.Visible = false;
         lblClient.Visible = true;
         chbBranch.Visible = false;
         lblb.Visible      = false;
         txtBranch.Visible = false;
         dtt = CarTable.GetTimesCars(ob, true, dtpFrom.Value, dtpTo.Value);
         //המשתנה מלמעלה
         dgv = new DataView(dtt);
         //המשתנה מהטופס
         dgvTableCar.DataSource = dgv;
         chbBranch.Checked      = false;
     }
     //להצגת כל הרכבים
     if (user != "client")
     {
         dtt = CarTable.GetDisplayTable();
         //המשתנה מלמעלה
         dgv = new DataView(dtt);
         //המשתנה מהטופס
         dgvTableCar.DataSource = dgv;
     }
     curentBranch   = new Branch(ob);
     txtBranch.Text = Convert.ToString(curentBranch.BranchName);
 }
Ejemplo n.º 15
0
        private void metroGrid3_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            List <CarTable> list = metroGrid3.DataSource as List <CarTable>;

            C1                     = list[e.RowIndex];
            TextBox3.Text          = C1.Car_company;
            TextBox4.Text          = C1.Car_name;
            TextBox12.Text         = C1.Model;
            TextBox13.Text         = C1.Price;
            TextBox14.Text         = C1.Colour;
            TextBox15.Text         = C1.Mileage;
            TextBox19.Text         = C1.Image_path;
            ComboBox5.SelectedItem = C1.Fuel_type;
            ComboBox6.SelectedItem = C1.Car_class;
        }
Ejemplo n.º 16
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     try
     {
         curentFix = new Fixs(Convert.ToInt32(txtSearch.Text));
         if (FillClass() == true)
         {
             curentFixTable.UpdateToAccess(curentFix);
             MessageBox.Show("תיקון התעדכן בהצלחה");
             Car curentCar = new Car(curentFix.CarNumber);
             curentCar.Fix = true;
             CarTable curentTable = new CarTable();
             curentTable.UpdateToAccess(curentCar);
         }
     }
     catch
     {
         MessageBox.Show("לא נמצאו תיקונים מתאימים");
     }
 }
Ejemplo n.º 17
0
        public ActionResult Edit(CarTable car)
        {
            var originalCar = (from c in _db.CarTable where c.Id == car.Id select c).First();

            if (!ModelState.IsValid)
            {
                return(View(originalCar));
            }

            //_db.CarTable.Add(car);
            //_db.CarTable.Attach(car);
            //var entry = _db.Entry(car);
            //entry.State = EntityState.Modified;
            originalCar.Brand       = car.Brand;
            originalCar.Year        = car.Year;
            originalCar.Description = car.Description;
            _db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 18
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            int p = Convert.ToInt32(cmbPlace.SelectedValue);

            if (CarTable.GetIfDelId(curentCar.CarNumber))
            {
                DialogResult dres = MessageBox.Show("האם למחוק", "אזהרת מחיקה", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                if (dres == DialogResult.Yes)
                {
                    curentTable.DeleteToAccess(curentCar);
                    MessageBox.Show("רכב הוסר בהצלחה");
                    ParkingInBranch curentp = new ParkingInBranch(p);
                    curentp.Fullparking = false;
                    curentt.UpdateToAccess(curentp);
                }
            }
            else
            {
                MessageBox.Show("לא ניתן למחוק את הרכב המבוקש");
            }
        }
Ejemplo n.º 19
0
 private void chbBranch_CheckedChanged(object sender, EventArgs e)
 {
     if (chbBranch.Checked == true)
     {
         //  dgv.RowFilter = "coudBranch="+ true ;
         dtt = CarTable.GetTimesCars(branchs, true, dtpFrom.Value, dtpTo.Value);
         //המשתנה מלמעלה
         dgv = new DataView(dtt);
         //המשתנה מהטופס
         dgvTableCar.DataSource = dgv;
     }
     if (chbBranch.Checked == false)
     {
         // dgv.RowFilter = "coudBranch="+ false  ;
         dtt = CarTable.GetTimesCars(branchs, false, dtpFrom.Value, dtpTo.Value);
         //המשתנה מלמעלה
         dgv = new DataView(dtt);
         //המשתנה מהטופס
         dgvTableCar.DataSource = dgv;
     }
 }
Ejemplo n.º 20
0
 public object TableSave(CarTable carTable)
 {
     try
     {
         using (DDContext context = new DDContext())
         {
             //carTable.UseKilometres = carTable.FactKilometre;
             context.CarTable.Add(carTable);
             context.SaveChanges();
         }
         return(new ErrorModel()
         {
             errorCode = 0,
             errorMessage = "添加成功"
         });
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 21
0
 public object TableSave(CarTable carTable)
 {
     try
     {
         using (DDContext context = new DDContext())
         {
             context.CarTable.Add(carTable);
             context.SaveChanges();
         }
         return(new NewErrorModel()
         {
             error = new Error(0, "添加成功!", "")
             {
             },
         });
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 22
0
        private void button1_Click(object sender, EventArgs e)
        {
            CarTable cardata = new CarTable()
            {
                RefuelingDate = dateTimePicker1.Value,
                Liter         = Convert.ToInt32(numericUpDown1.Value),
                Kilometer     = Convert.ToInt32(numericUpDown2.Value)
            };

            try
            {
                CartotalModel cartotal = new CartotalModel();
                cartotal.CarTable.Add(cardata);
                cartotal.SaveChanges();
                MessageBox.Show("存檔完成");
            }
            catch (Exception ex)
            {
                MessageBox.Show($"發生錯誤{ex.ToString()}");
            }
        }
Ejemplo n.º 23
0
        private void btnok_Click(object sender, EventArgs e)
        {
            try {
                curentTake = new Takes(Convert.ToInt32(txtnumTake.Text));
                Car curentCar = new Car(curentTake.NumCar);
                curentCar.Finds = false;
                CarTable curentCarTable = new CarTable();
                curentCarTable.UpdateToAccess(curentCar);
                MessageBox.Show("תודה שהשכרתם באלבר");
                //עדכון שהחניה פנויה
                curentParking             = new ParkingInBranch(curentCar.CoudeParking);
                curentParking.Fullparking = false;
                curentParkingTable.UpdateToAccess(curentParking);
            }
            catch
            {
                MessageBox.Show("לא נמצא לקוח במאגר וודא שהקלדת נכון את ת.ז");
            }
            frmReportTakeCar f1 = new frmReportTakeCar(curentTake.NumTakes);

            f1.Show();
            this.Close();
        }
Ejemplo n.º 24
0
 public object TableModify(CarTable carTable)
 {
     try
     {
         using (DDContext context = new DDContext())
         {
             context.Entry <CarTable>(carTable).State = System.Data.Entity.EntityState.Modified;
             context.SaveChanges();
         }
         return(new ErrorModel()
         {
             errorCode = 0,
             errorMessage = "修改成功"
         });
     }
     catch (Exception ex)
     {
         return(new ErrorModel()
         {
             errorCode = 1,
             errorMessage = ex.Message
         });
     }
 }
Ejemplo n.º 25
0
        public async Task <NewErrorModel> GetPrintPDF([FromBody] PrintAndSendModel printAndSendModel)
        {
            try
            {
                string    TaskId    = printAndSendModel.TaskId;
                string    UserId    = printAndSendModel.UserId;
                PDFHelper pdfHelper = new PDFHelper();
                using (DDContext context = new DDContext())
                {
                    //获取表单信息
                    Tasks  tasks  = context.Tasks.Where(t => t.TaskId.ToString() == TaskId && t.NodeId == 0).First();
                    string FlowId = tasks.FlowId.ToString();

                    TasksState tasksState = context.TasksState.Where(t => t.TaskId == TaskId).FirstOrDefault();
                    if (tasksState.State != "已完成")
                    {
                        return(new NewErrorModel()
                        {
                            error = new Error(1, string.Format("流程{0}!", tasksState.State), "")
                            {
                            },
                        });
                    }
                    CarTable ct = context.CarTable.Where(u => u.TaskId == TaskId).FirstOrDefault();
                    if (printAndSendModel.IsPublic)
                    {
                        ct.CarId = context.Car.Where(c => c.Id.ToString() == ct.CarId).FirstOrDefault().CarNumber;
                    }
                    Dictionary <string, string> keyValuePairs = new Dictionary <string, string>();

                    if (printAndSendModel.IsPublic)
                    {
                        keyValuePairs.Add("驾驶人", ct.DrivingMan);
                        keyValuePairs.Add("车牌号", ct.CarId);
                        keyValuePairs.Add("同行人数", ct.PeerNumber);
                        keyValuePairs.Add("用车事由", ct.MainContent);
                        keyValuePairs.Add("计划行车路线", ct.PlantTravelWay);
                        keyValuePairs.Add("实际行车路线", ct.FactTravelWay);
                        keyValuePairs.Add("出发时间", ct.StartTime.ToString());
                        keyValuePairs.Add("归来时间", ct.EndTime.ToString());
                        keyValuePairs.Add("实际行驶公里数", ct.FactKilometre);
                        keyValuePairs.Add("总行驶公里数", ct.UseKilometres);
                    }
                    else
                    {
                        keyValuePairs.Add("驾驶人", ct.DrivingMan);
                        keyValuePairs.Add("同行人数", ct.PeerNumber);
                        keyValuePairs.Add("用车事由", ct.MainContent);
                        keyValuePairs.Add("计划行车路线", ct.PlantTravelWay);
                        keyValuePairs.Add("实际行车路线", ct.FactTravelWay);
                        keyValuePairs.Add("出发时间", ct.StartTime.ToString());
                        keyValuePairs.Add("归来时间", ct.EndTime.ToString());
                        keyValuePairs.Add("总行驶公里数", ct.UseKilometres);
                    }

                    List <NodeInfo> NodeInfoList = context.NodeInfo.Where(u => u.FlowId == FlowId && u.NodeId != 0 && u.IsSend != true && u.NodeName != "结束").ToList();
                    foreach (NodeInfo nodeInfo in NodeInfoList)
                    {
                        if (string.IsNullOrEmpty(nodeInfo.NodePeople))
                        {
                            string strNodePeople = context.Tasks.Where(q => q.TaskId.ToString() == TaskId && q.NodeId == nodeInfo.NodeId).First().ApplyMan;
                            string ApplyTime     = context.Tasks.Where(q => q.TaskId.ToString() == TaskId && q.NodeId == nodeInfo.NodeId).First().ApplyTime;
                            nodeInfo.NodePeople = strNodePeople + "  " + ApplyTime;
                        }
                        else
                        {
                            string ApplyTime = context.Tasks.Where(q => q.TaskId.ToString() == TaskId && q.NodeId == nodeInfo.NodeId).First().ApplyTime;
                            nodeInfo.NodePeople = nodeInfo.NodePeople + "  " + ApplyTime;
                        }
                    }
                    DataTable dtApproveView = ClassChangeHelper.ToDataTable(NodeInfoList);
                    string    FlowName      = context.Flows.Where(f => f.FlowId.ToString() == FlowId).First().FlowName.ToString();


                    string path = pdfHelper.GeneratePDF(FlowName, TaskId, tasks.ApplyMan, tasks.Dept, tasks.ApplyTime,
                                                        null, null, "2", 300, 650, null, null, null, dtApproveView, keyValuePairs);
                    string RelativePath = "~/UploadFile/PDF/" + Path.GetFileName(path);

                    List <string> newPaths = new List <string>();
                    RelativePath = AppDomain.CurrentDomain.BaseDirectory + RelativePath.Substring(2, RelativePath.Length - 2).Replace('/', '\\');
                    newPaths.Add(RelativePath);
                    string SavePath = string.Format(@"{0}\UploadFile\Ionic\{1}.zip", AppDomain.CurrentDomain.BaseDirectory, FlowName + DateTime.Now.ToString("yyyyMMddHHmmss"));
                    //文件压缩打包
                    IonicHelper.CompressMulti(newPaths, SavePath, false);

                    //上传盯盘获取MediaId
                    SavePath = string.Format(@"~\UploadFile\Ionic\{0}", Path.GetFileName(SavePath));
                    DingTalkServersController dingTalkServersController = new DingTalkServersController();
                    var resultUploadMedia = await dingTalkServersController.UploadMedia(SavePath);

                    //推送用户
                    FileSendModel fileSendModel = JsonConvert.DeserializeObject <FileSendModel>(resultUploadMedia);
                    fileSendModel.UserId = UserId;
                    var result = await dingTalkServersController.SendFileMessage(fileSendModel);

                    return(new NewErrorModel()
                    {
                        data = result,
                        error = new Error(0, "打印盖章成功!", "")
                        {
                        },
                    });
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 26
0
        public object TableModify(CarTable carTable)
        {
            try
            {
                using (DDContext context = new DDContext())
                {
                    carTable.FactKilometre = carTable.UseKilometres;
                    Tasks tasks = context.Tasks.Where(t => t.TaskId.ToString() == carTable.TaskId && t.State == 0 && t.IsEnable == 1).FirstOrDefault();
                    if (tasks.NodeId == 4)
                    {
                        if (!string.IsNullOrEmpty(carTable.OccupyCarId) && !string.IsNullOrEmpty(carTable.FactKilometre))
                        {
                            CarTable carTableOld = context.CarTable.Find(int.Parse(carTable.OccupyCarId));
                            carTableOld.FactKilometre = (float.Parse(carTableOld.FactKilometre) - float.Parse(carTable.FactKilometre)).ToString();
                            context.Entry <CarTable>(carTableOld).State = System.Data.Entity.EntityState.Modified;
                            context.SaveChanges();
                        }
                    }
                    context.Entry <CarTable>(carTable).State = System.Data.Entity.EntityState.Modified;
                    context.SaveChanges();

                    //if (!string.IsNullOrEmpty(carTable.CarId) && carTable.StartKilometres == null)
                    //{
                    //    Car car = context.Car.Find(Int32.Parse(carTable.CarId));
                    //    //只保留五条最新数据
                    //    if (!string.IsNullOrEmpty(car.UseTimes))
                    //    {
                    //        if (car.UseTimes.Split(',').Length < 5)
                    //        {
                    //            car.UseTimes = car.UseTimes + "," + carTable.StartTime + "~" + carTable.EndTime;
                    //            car.UseMan = car.UseMan + "," + carTable.DrivingMan;
                    //        }
                    //        else
                    //        {
                    //            car.UseTimes = car.UseTimes.Substring(car.UseTimes.IndexOf(','), car.UseTimes.Length - car.UseTimes.IndexOf(','));
                    //            car.UseMan = car.UseMan.Substring(car.UseMan.IndexOf(','), car.UseMan.Length - car.UseMan.IndexOf(','));
                    //            car.UseTimes = car.UseTimes + "," + carTable.StartTime + "~" + carTable.EndTime;
                    //            car.UseMan = car.UseMan + "," + carTable.DrivingMan;
                    //        }
                    //    }
                    //    else
                    //    {
                    //        car.UseTimes = carTable.StartTime + "~" + carTable.EndTime;
                    //        car.UseMan = carTable.DrivingMan;
                    //    }
                    //    car.OccupyCarId = carTable.Id.ToString();
                    //    car.FinnalStartTime = carTable.StartTime;
                    //    car.FinnalEndTime = carTable.EndTime;
                    //    context.Entry<Car>(car).State = System.Data.Entity.EntityState.Modified;
                    //    context.SaveChanges();
                    //}

                    //if (string.IsNullOrEmpty(carTable.OccupyCarId) && !string.IsNullOrEmpty(carTable.UseKilometres))
                    //{
                    //    //判断当前处理节点为车辆管理员确认公里数
                    //    if (context.Tasks.Where(t => t.TaskId.ToString() == carTable.TaskId && t.State == 0 && t.IsEnable == 1).FirstOrDefault().NodeId == 4)
                    //    {
                    //        carTable.FactKilometre = carTable.UseKilometres;
                    //        context.Entry<CarTable>(carTable).State = System.Data.Entity.EntityState.Modified;
                    //        context.SaveChanges();
                    //    }
                    //}
                    ////扣除公里数
                    //if (!string.IsNullOrEmpty(carTable.OccupyCarId) && !string.IsNullOrEmpty(carTable.UseKilometres))
                    //{
                    //    //判断当前处理节点为车辆管理员确认公里数
                    //    if (context.Tasks.Where(t => t.TaskId.ToString() == carTable.TaskId && t.State == 0 && t.IsEnable == 1).FirstOrDefault().NodeId == 4)
                    //    {
                    //        CarTable carTableNew = context.CarTable.Find(Int32.Parse(carTable.OccupyCarId));
                    //        carTableNew.FactKilometre = (float.Parse(carTableNew.FactKilometre) - float.Parse(carTable.UseKilometres)).ToString();
                    //        context.Entry<CarTable>(carTableNew).State = System.Data.Entity.EntityState.Modified;
                    //        context.SaveChanges();

                    //        carTable.FactKilometre = carTable.UseKilometres;
                    //        context.Entry<CarTable>(carTable).State = System.Data.Entity.EntityState.Modified;
                    //        context.SaveChanges();
                    //    }
                    //}
                }
                return(new ErrorModel()
                {
                    errorCode = 0,
                    errorMessage = "修改成功"
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }