private void btSave_Click(object sender, EventArgs e) { try { if (this.cbLineNum.Text.Trim().Length < 1) { MessageBox.Show("请选择生产线!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } if (this.cbProductioName.Text.Trim().Length < 1) { MessageBox.Show("请填写产品名称!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } if (this.txtPlan_Num.Text.Trim().Length < 1) { MessageBox.Show("请填写预计产量!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } if (this.cbShift.Text.Trim().Length < 1) { MessageBox.Show("请选择班次!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } if (isUpdate) { plan.Pline_ID = this.cbLineNum.SelectedIndex; plan.BreakeID = this.cbProductioName.Text.Trim(); plan.PlanNum = Convert.ToInt32(this.txtPlan_Num.Text.Trim()); plan.Actual_num = Convert.ToInt32(this.txtActualNum.Text.Trim()); plan.StartTime = this.dtpDateStart.Value; plan.EndTime = this.dtpDateEnd.Value; plan.Shift = this.cbShift.SelectedIndex; plan.Remark = this.txtRemark.Text.Trim(); } else { plan = new ProductionPlanMDL(); plan.PlanID = string.Format("{0}_{1}", this.dtpDateStart.Value.ToString("yyyyMMdd"), this._lineID); plan.Pline_ID = this.cbLineNum.SelectedIndex; plan.BreakeID = this.cbProductioName.Text.Trim(); plan.PlanNum = Convert.ToInt32(this.txtPlan_Num.Text.Trim()); plan.StartTime = this.dtpDateStart.Value; plan.EndTime = this.dtpDateEnd.Value; plan.Shift = this.cbShift.SelectedIndex; plan.CreateTime = DateTime.Now; plan.Remark = this.txtRemark.Text.Trim(); } //info.Remark = this.txtRemark.Text.Trim(); this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
/// <summary> /// 插入单项产品计划 /// </summary> /// <param name="mdl"></param> /// <returns></returns> public int InsertProductionPlanItem(ProductionPlanMDL mdl) { int ret = 0; string strSql = string.Empty; try { strSql = "insert into production_plan (plan_id,pline_id,station_id,start_time,end_time,brakeid,plan_num,actual_num,shift,create_time,remark)" + "values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')"; strSql = string.Format(strSql, mdl.PlanID, mdl.Pline_ID, mdl.Station_ID, mdl.StartTime.ToString("yyyy-MM-dd HH:mm:ss"), mdl.EndTime.ToString("yyyy-MM-dd HH:mm:ss"), mdl.BreakeID, mdl.PlanNum, mdl.Actual_num, mdl.Shift, mdl.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), mdl.Remark); ret = MySqlDBHelper.ExecuteNonQuery(MySqlDBHelper.Conn, CommandType.Text, strSql, null); return(ret); } catch (Exception ex) { CLog.WriteErrLogInTrace(ex.Message); return(0); } }
/// <summary> /// 获取产品计划通过序号ID /// </summary> /// <param name="planid"></param> /// <returns></returns> public ProductionPlanMDL GetProductionPalnByID(int tid) { try { ProductionPlanMDL mdl = new ProductionPlanMDL(); DataSet dataSet = null; string strSql = "select * from production_plan where tid='{0}' "; strSql = string.Format(strSql, tid); dataSet = MySqlDBHelper.ExecuteDataSet(MySqlDBHelper.Conn, CommandType.Text, strSql); if (dataSet != null) { DataRow row = dataSet.Tables[0].Rows[0]; mdl.Prase(row); return(mdl); } return(null); } catch (Exception ex) { CLog.WriteErrLogInTrace(ex.Message); return(null); } }
/// <summary> /// 更新产品计划信息 /// </summary> /// <param name="info"></param> public int UpdateProductionPlanItem(ProductionPlanMDL mdl) { int ret = 0; string strSql = string.Empty; try { //(plan_id,pline_id,station_id,start_time,end_time,brakeid,plan_num,actual_num,shift,create_time,remark) strSql = "update production_plan set plan_id='{0}',pline_id='{1}',station_id='{2}',start_time='{3}',end_time='{4}',brakeid='{5}',plan_num='{6}'," + "actual_num='{7}',shift='{8}',create_time='{9}',remark='{10}' where tid='{11}'"; strSql = string.Format(strSql, mdl.PlanID, mdl.Pline_ID, mdl.Station_ID, mdl.StartTime.ToString("yyyy-MM-dd HH:mm:ss"), mdl.EndTime.ToString("yyyy-MM-dd HH:mm:ss"), mdl.BreakeID, mdl.PlanNum, mdl.Actual_num, mdl.Shift, mdl.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), mdl.Remark, mdl.TID); //ret = MySqlDBHelper.ExecuteNonQuery(MySqlDBHelper.Conn, CommandType.Text, strSql, null); ret = SQLiteDBHelper.ExecuteNonQuery(strSql); return(ret); } catch (Exception ex) { CLog.WriteErrLogInTrace(ex.Message); return(0); } }
/// <summary> /// Handles the AppointmentEdit event of the calendar control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Syd.ScheduleControls.Events.AppointmentEditEventArgs"/> instance containing the event data.</param> private void calendar_AppointmentEdit(object sender, AppointmentEditEventArgs e) { //show a dialog to edit the appointment using (PlaninfoItemForm dialog = new PlaninfoItemForm()) { dialog.AppointmentDateStart = e.Appointment.DateStart; dialog.AppointmentDateEnd = e.Appointment.DateEnd; dialog.LineID = this.cbPLine.SelectedIndex + 1; ProductionPlanDal dal = new ProductionPlanDal(); ProductionPlanMDL mdl = dal.GetProductionPalnByID(((BrakePlanAppointments)e.Appointment).MDL.TID); if (mdl != null) { dialog.IsUpdate = true; dialog.ProductionPlan = mdl; } else { dialog.IsUpdate = false; } DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { int ret = -1; if (dialog.IsUpdate) { ret = dal.UpdateProductionPlanItem(dialog.ProductionPlan); } else { ret = dal.InsertProductionPlanItem(dialog.ProductionPlan); } if (ret > 0) { LoadPlanGrid(); // //if the user clicked 'save', update the appointment dates and title //e.Appointment.DateStart = dialog.AppointmentDateStart; //e.Appointment.DateEnd = dialog.AppointmentDateEnd; //e.Appointment.Subject =dialog.ProductionPlan.BreakeID + ":" + dialog.ProductionPlan.PlanNum.ToString(); ////have to tell the controls to refresh appointment display //dayView1.RefreshAppointments(); MessageBox.Show("修改数据成功!"); //dayView1.Invalidate(); } else { MessageBox.Show("修改数据失败!"); } } else if (result == DialogResult.Abort) { int ret = dal.DeleteProudctionPlanItem(dialog.ProductionPlan.TID); if (ret > 0) { LoadPlanGrid(); // //if the user clicked 'save', update the appointment dates and title //e.Appointment.DateStart = dialog.AppointmentDateStart; //e.Appointment.DateEnd = dialog.AppointmentDateEnd; //e.Appointment.Subject =dialog.ProductionPlan.BreakeID + ":" + dialog.ProductionPlan.PlanNum.ToString(); ////have to tell the controls to refresh appointment display //dayView1.RefreshAppointments(); MessageBox.Show("删除数据成功!"); //dayView1.Invalidate(); } else { MessageBox.Show("删除数据失败!"); } } } }
/// <summary> /// 获取产线点 /// </summary> /// <param name="table"></param> /// <returns></returns> private AppointmentList GetPlanPoints(DataTable table) { try { AppointmentList list = new AppointmentList(); DateTime timeStart = new DateTime(this.dateTimePicker1.Value.Year, this.dateTimePicker1.Value.Month, this.dateTimePicker1.Value.Day, 7, 30, 0); DateTime timeEnd = timeStart; int hoursToAdd = 1; int minuteToAdd = 60; List <TimeRange> rangs = new List <TimeRange>(); //获取小时 for (int i = 0; i < 12; i++) { timeStart = timeStart.AddHours(hoursToAdd); timeEnd = timeStart.AddMinutes(minuteToAdd); TimeRange rang = new TimeRange(); rang.StartTime = timeStart; rang.EndTime = timeEnd; rangs.Add(rang); } foreach (DataRow itemRow in table.Rows) { foreach (TimeRange item in rangs) { DateTime ptime1 = Convert.ToDateTime(itemRow["start_time"].ToString()); DateTime ptime2 = Convert.ToDateTime(itemRow["end_time"]); if (item.IsInFullRange(ptime1, ptime2)) { ProductionPlanMDL mdl = new ProductionPlanMDL(); mdl.Prase(itemRow); BrakePlanAppointments app = new BrakePlanAppointments(); app.Subject = string.Format("型号:{0} 预计产量:{1}实际产量:{2}", mdl.BreakeID.ToString(), mdl.PlanNum.ToString(), mdl.Actual_num.ToString()); app.ColorBlockBrush = Brushes.OrangeRed; app.DateStart = ptime1; app.DateEnd = ptime2; app.MDL = mdl; list.Add(app); break; } if (item.IsInRange(ptime1)) { ProductionPlanMDL mdl = new ProductionPlanMDL(); mdl.Prase(itemRow); BrakePlanAppointments app = new BrakePlanAppointments(); app.Subject = string.Format("型号:{0} 预计产量:{1}/r/n实际产量:{2}", mdl.BreakeID.ToString(), mdl.PlanID.ToString(), mdl.Actual_num.ToString()); app.ColorBlockBrush = Brushes.OrangeRed; app.DateStart = ptime1; app.DateEnd = ptime2; app.MDL = mdl; list.Add(app); break; } } } return(list); } catch (Exception ex) { CLog.WriteErrLogInTrace(ex.StackTrace); return(null); } }