示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            decimal addhours   = 0;
            decimal newhours   = 0;
            decimal starthours = 0;

            if (state == "中断" || state == "过时")
            {
                ClsBLL.ServicePauseStart(RecordID);//如果是中断则结束中断
            }
            if (txtAddHours.Text != string.Empty)
            {
                addhours = decimal.Parse(txtAddHours.Text);
                addhours = decimal.Parse(addhours.ToString()) / 100;
            }
            newhours = addhours + decimal.Parse(txtHours.Text) / 100;
            //新的计划完成时间=当前时间+追加工时
            starthours = ClsBLL.GetFactHours(RecordID);
            if (newhours > starthours)
            {
                starthours = newhours - starthours;  //预计维修工时减实际做过
            }
            DateTime plancompletetime = DateTime.Now.AddMinutes(double.Parse(Convert.ToString(starthours * 60)));

            try
            {
                string sqlstring = "Update booking set State='维修进行中',StartServiceTime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "',Worker='" + comboBox1.Text + "' ,ServiceHour=" + newhours + ",PlanCompleteTime='" + plancompletetime + "',Remark=isnull(Remark,'')+'," + this.Text + txtAddHours.Text + "TU' where ID=" + RecordID;
                if (txtAddHours.Text != string.Empty)
                {
                    sqlstring += ";Insert Into ServiceAddHours(BookID,OldHours,AddHours,Worker,AddTime)values(" + RecordID + "," + decimal.Parse(txtHours.Text) / 100 + "," + decimal.Parse(txtAddHours.Text) / 100 + ",'" + comboBox1.Text + "','" + DateTime.Today.ToShortTimeString() + "')";
                }
                if (SQLDbHelper.ExecuteSql(sqlstring) > 0)
                {
                    DialogResult = DialogResult.OK;
                    ClsBLL.AddMsg(RecordID, "车牌号码:" + this.Text + txtAddHours.Text + "TU--" + ClsBLL.UserName);
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
            }
            catch (Exception Err)
            {
                MessageBox.Show(Err.Message);
            }
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //维修工时
            if (dataGridView1.Rows.Count == 0)
            {
                return;
            }
            if (dataGridView1.Rows[0].Cells[1].Value == null)
            {
                MessageBox.Show("请填写分单派工!");
                return;
            }
            DateTime starttime = DateTime.Parse(DateTime.Today.ToString("yyyy-MM-dd") + " " + ClsBLL.GetSet("txtSet1"));

            try
            {
                string  worker       = string.Empty;
                decimal servicehours = 0;
                servicehours = servicehours / 100;
                string   serviceitem      = string.Empty;
                int      id               = -1;
                DateTime StartServiceTime = DateTime.Now;
                DateTime DtPlanComplete   = DateTime.Now;

                string insertstring = string.Empty;
                string sqlstring    = "Select count(Distinct CreateDate) from Booking where AssignTime between '" + DateTime.Today.ToString() + "' and '" + DateTime.Today.AddDays(1).ToString() + "' And Remark like '%分单%'";
                int    fendan       = int.Parse(SQLDbHelper.ExecuteScalar(sqlstring).ToString());
                fendan++;
                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    id = -1;
                    if (dataGridView1.Rows[i].Cells[1].Value != null)
                    {
                        worker       = dataGridView1.Rows[i].Cells[0].Value.ToString();
                        servicehours = decimal.Parse(dataGridView1.Rows[i].Cells[1].Value.ToString());
                        servicehours = servicehours / 100;
                        serviceitem  = dataGridView1.Rows[i].Cells[2].Value.ToString();
                        if (dataGridView1.Rows[i].Cells[3].Value != null)
                        {
                            id = int.Parse(dataGridView1.Rows[i].Cells[3].Value.ToString());
                        }
                        DtPlanComplete = DateTime.Now.AddMinutes(double.Parse(Convert.ToString(servicehours * 60)));
                        if (DateTime.Now.CompareTo(starttime) < 0)
                        {
                            DtPlanComplete = starttime;
                        }
                        if (id == -1)
                        {
                            if (i == 0) //未派工,首次分单
                            {
                                sqlstring = "Update Booking Set AssignTime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "',StartServiceTime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "',PlanCompleteTime='" + DtPlanComplete + "', Worker='" + worker + "',ServiceHour=" + servicehours + ",ServiceItem='" + serviceitem + "',State='维修进行中',Remark=isnull(Remark,'')+',分单" + fendan + "' where ID=" + RID;
                                SQLDbHelper.ExecuteSql(sqlstring);
                            }
                            else
                            {
                                insertstring += ";Insert Into Booking(BookIndex,booktime,carno,vin,cartype,linkman,tel,worker,bookhour,servicehour,serviceitem,";
                                insertstring += "servicetype,state,CarTopNo,Creator,Createdate,Updatedate,Success,ComeTime,AssignTime,PlanOutTime,PlanCompleteTime,StartServiceTime,Remark,IsBook,IsRemind,IsRemindSuc,";
                                insertstring += "RemindResult,Receiver,LastUpdate,PreSA,RunKM,Email,SendService,PreParts,Parts)";
                                insertstring += "Select BookIndex,booktime,carno,vin,cartype,linkman,tel,'" + worker + "' as worker,bookhour," + servicehours + " as servicehour,'" + serviceitem + "' as serviceitem,";
                                insertstring += "Servicetype,'维修进行中',CarTopNo,Creator,Createdate,Updatedate,Success,ComeTime,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "',PlanOutTime,'" + DtPlanComplete + "' as PlanCompleteTime,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "' as StartServiceTime,Remark,IsBook,IsRemind,IsRemindSuc,";
                                insertstring += "RemindResult,Receiver,LastUpdate,PreSA,RunKM,Email,SendService,PreParts,Parts from booking where ID=" + RID;
                            }
                        }
                        else //已派工,分单
                        {
                            DataRow[] Drs = Dt.Select("ID=" + id);
                            if (remark.IndexOf("分单") > -1)
                            {
                                if (Drs.Length > 0)
                                {
                                    if (Drs[0]["State"].ToString() == "延时到明天")
                                    {
                                        decimal facthour = ClsBLL.GetFactHours(id);
                                        if (servicehours > facthour)
                                        {
                                            servicehours = servicehours - facthour;
                                        }
                                        DtPlanComplete = DateTime.Now.AddMinutes(double.Parse(Convert.ToString(servicehours * 60)));
                                        sqlstring      = "Update Booking Set ServiceHour=" + servicehours + ",StartServiceTime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "',PlanCompleteTime='" + DtPlanComplete + "',ServiceItem='" + serviceitem + "',State='维修进行中' where ID=" + id;
                                    }
                                    else
                                    {
                                        sqlstring = "Update Booking Set ServiceHour=" + servicehours + ",ServiceItem='" + serviceitem + "',State='维修进行中' where ID=" + id;
                                    }
                                }
                            }
                            else
                            {
                                if (Drs[0]["State"].ToString() == "延时到明天")
                                {
                                    decimal facthour = ClsBLL.GetFactHours(id);
                                    if (servicehours > facthour)
                                    {
                                        servicehours = servicehours - facthour;
                                    }
                                    DtPlanComplete = DateTime.Now.AddMinutes(double.Parse(Convert.ToString(servicehours * 60)));
                                    sqlstring      = "Update Booking Set ServiceHour=" + servicehours + ",StartServiceTime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "',PlanCompleteTime='" + DtPlanComplete + "',ServiceItem='" + serviceitem + "',State='维修进行中',Remark=isnull(Remark,'')+',分单" + fendan + "' where ID=" + id;
                                }
                                else
                                {
                                    sqlstring = "Update Booking Set ServiceHour=" + servicehours + ",PlanCompleteTime='" + DtPlanComplete + "',ServiceItem='" + serviceitem + "',State='维修进行中',Remark=isnull(Remark,'')+',分单" + fendan + "' where ID=" + id;
                                }
                            }
                            SQLDbHelper.ExecuteSql(sqlstring);
                        }
                    }
                }
                if (insertstring.StartsWith(";"))
                {
                    SQLDbHelper.ExecuteSql(insertstring.Substring(1));
                }
                MessageBox.Show("保存成功!");
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception Err)
            {
                MessageBox.Show(Err.Message);
            }
        }