예제 #1
0
        public static JobModel GetModelIndex(string modelText, List <Index> lst, int index)
        {
            JobModel jMod = default;

            foreach (var item in lst)
            {
                if (item.ObjText != modelText)
                {
                    continue;
                }
                var jIndex = lst.LastOrDefault(x => x.RowIndex == item.RowIndex && x.ObjIndex == item.ObjIndex + index);
                if (jIndex != null)
                {
                    jMod = Central.TaskList
                           .FirstOrDefault(x => x.Name == jIndex.ObjText &&
                                           x.Aim == jIndex.ObjAim && x.Department == jIndex.ObjDept && x.Idx == jIndex.Idx);
                }
                else
                {
                    jMod = null;
                }
            }
            return(jMod);
        }
예제 #2
0
        private void SaveData()
        {
            var selectedDate = dtpCommData.Value;

            tableView1.Invalidate();
            tableView1.EndEdit();
            var groupForDelete = from prod in Tables.Productions
                                 where prod.Commessa == Workflow.TargetOrder &&
                                 prod.Line == Workflow.TargetLine &&
                                 prod.Department == Workflow.TargetDepartment
                                 select prod;
            var items = groupForDelete.ToList();

            foreach (var item in items)
            {
                Tables.Productions.DeleteOnSubmit(item);
            }
            Config.GetGanttConn().SubmitChanges();
            if (!string.IsNullOrEmpty(txtCommCapi.Text) && !string.IsNullOrEmpty(txtPersone.Text))
            {
                bool wantToSave = true;
                if (!_deleting && selectedDate.DayOfWeek == DayOfWeek.Saturday || selectedDate.DayOfWeek == DayOfWeek.Sunday)
                {
                    var diag = MessageBox.Show("Are you sure you want to add production for " +
                                               selectedDate.DayOfWeek.ToString() + "?", "Workflow controller", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    wantToSave = diag == DialogResult.Yes ? true : false;
                }
                if (!wantToSave)
                {
                    return;
                }
                InsertNewRecord();
                txtCommCapi.Text = "";
                txtCommCapi.Focus();
            }

            lblSavedInfo.Visible  = true;
            lblSavedInfo.Location = new Point(Width / 2 - lblSavedInfo.Width / 2, lblSavedInfo.Location.Y);
            lblSavedInfo.BringToFront();
            lblSavedInfo.Refresh();

            foreach (DataRow dr in _dtComm.Rows)
            {
                int.TryParse(dr[9].ToString(), out var dQ);
                double.TryParse(dr[10].ToString(), out var price);
                bool.TryParse(dr[11].ToString(), out var incHours);
                int.TryParse(dr[12].ToString(), out var abatim);
                double.TryParse(dr[13].ToString(), out var qtyH);
                var shift = dr[14].ToString();
                double.TryParse(dr[15].ToString(), out var settingHours);

                var pd = new Production
                {
                    Data         = Convert.ToDateTime(dr[1].ToString()),
                    Commessa     = dr[2].ToString(),
                    Capi         = Convert.ToInt32(dr[3]),
                    Line         = dr[4].ToString(),
                    Members      = Convert.ToInt32(dr[5]),
                    Department   = dr[6].ToString(),
                    Abovenormal  = Convert.ToBoolean(dr[7]),
                    Times        = Convert.ToDateTime(dr[8].ToString()),
                    Dailyqty     = dQ,
                    Price        = price,
                    IncludeHours = incHours,
                    Abatim       = abatim,
                    QtyH         = qtyH,
                    Shift        = shift,
                    SettingHours = settingHours,
                };
                Tables.Productions.InsertOnSubmit(pd);
            }
            try
            {
                Config.GetGanttConn().SubmitChanges();
                if (tableView1.Rows.Count <= 0)
                {
                    using (var context = new System.Data.Linq.DataContext(Central.SpecialConnStr))
                    {
                        context.ExecuteCommand("update objects set " +
                                               "startprod={0},endprod={1},prodqty={2},delayts={3}, delaystart={4},delayend={5} " +
                                               "where ordername={6} and aim={7} and department={8}",
                                               0L,
                                               0L,
                                               0L, 0L, 0L, 0L,
                                               Workflow.TargetOrder, Workflow.TargetLine, Workflow.TargetDepartment);
                    }
                }
                else
                {
                    var jMod = new JobModel();
                    jMod.GetJobContinum(Workflow.TargetOrder, Workflow.TargetLine, Workflow.TargetDepartment);
                }

                var menu = new Central();
                menu.GetBase();
            }
            catch (Exception ex)
            {
                lblSavedInfo.Visible = false;
                lblSavedInfo.Refresh();
                MessageBox.Show(ex.Message);
            }
            if (Width < 700)
            {
                Close();
            }
            else
            {
                ShowProductionDateRange();
                System.Threading.Thread.Sleep(200);
                lblSavedInfo.Visible = false;
                lblSavedInfo.Refresh();
            }
        }
예제 #3
0
        private void SaveData()
        {
            int.TryParse(txtCommCapi.Text, out var newCapi);
            var splitQty = _originalCapi - newCapi;
            var j        = new JobModel();

            var jobModel = (from jobs in Central.TaskList
                            where jobs.Name ==
                            Order &&
                            jobs.Aim == Aim &&
                            jobs.Department == Department
                            select jobs).SingleOrDefault();

            if (splitQty < 0)
            {
                MessageBox.Show("Value must be between 0 and maximum qty by 'commessa'");
                return;
            }

            try
            {
                using (var con = new System.Data.SqlClient.SqlConnection(Central.SpecialConnStr))
                {
                    //startdate,duration,enddate
                    var newDur      = j.CalculateJobDuration(Aim, splitQty, jobModel.QtyH, jobModel.Department);
                    var startdate   = jobModel.StartDate;
                    var endDate     = startdate.AddDays(+newDur);
                    var updateQuery = "update objects set loadedQty=@param1, StartDate=@paramStart, duration=@paramDur, endDate=@paramEnd where ordername=@param2 and aim=@param3 and department=@param4";
                    var cmd         = new System.Data.SqlClient.SqlCommand(updateQuery, con);
                    cmd.Parameters.Add("@param1", SqlDbType.Int).Value        = splitQty;
                    cmd.Parameters.Add("@param2", SqlDbType.NVarChar).Value   = Order;
                    cmd.Parameters.Add("@param3", SqlDbType.NVarChar).Value   = Aim;
                    cmd.Parameters.Add("@param4", SqlDbType.NVarChar).Value   = Department;
                    cmd.Parameters.Add("@paramDur", SqlDbType.Int).Value      = newDur;
                    cmd.Parameters.Add("@paramStart", SqlDbType.BigInt).Value = JobModel.GetLSpan(startdate);
                    cmd.Parameters.Add("@paramEnd", SqlDbType.BigInt).Value   = JobModel.GetLSpan(endDate);
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                }

                var q = "insert into objects (ordername,aim,article,stateid,loadedqty,qtyh,startdate,duration,enddate,dvc,rdd,startprod,endprod,dailyprod,prodqty, " +
                        "overqty,prodoverdays,delayts,prodoverts,locked,holiday,closedord,artprice,hasprod,lockedprod,delaystart,delayend,doneprod,base,department) values " +
                        "(@param1,@param2,@param3,@param4,@param5,@param6,@param7,@param8,@param9,@param10," +
                        "@param11,@param12,@param13,@param14,@param15,@param16,@param17,@param18,@param19," +
                        "@param20,@param21,@param22,@param23,@param24,@param25,@param26,@param27,@param28,@param29,@param30)";

                var jobDuration = j.CalculateJobDuration(cbCommLinea.Text, newCapi, jobModel.QtyH, Department);    //production duration

                var end   = JobModel.GetLineNextDate(cbCommLinea.Text, Workflow.TargetDepartment);
                var eDate = end.AddDays(+jobDuration);

                var splitStartDate = JobModel.GetLineNextDate(cbCommLinea.Text, Workflow.TargetDepartment);

                if (splitStartDate == Config.MinimalDate)
                {
                    splitStartDate = dtpCommData.Value;
                }

                using (var con = new System.Data.SqlClient.SqlConnection(Central.SpecialConnStr))
                {
                    var cmd = new System.Data.SqlClient.SqlCommand(q, con);
                    cmd.Parameters.Add("@param1", SqlDbType.NVarChar).Value              = Order + "_1";
                    cmd.Parameters.Add("@param2", SqlDbType.NVarChar).Value              = cbCommLinea.Text;
                    cmd.Parameters.Add("@param3", SqlDbType.NVarChar).Value              = jobModel.Article;
                    cmd.Parameters.Add("@param4", SqlDbType.Int).Value                   = 1;
                    cmd.Parameters.Add("@param5", SqlDbType.Int).Value                   = newCapi;
                    cmd.Parameters.Add("@param6", SqlDbType.Float).Value                 = jobModel.QtyH;;
                    cmd.Parameters.Add("@param7", System.Data.SqlDbType.BigInt).Value    = splitStartDate;
                    cmd.Parameters.Add("@param8", System.Data.SqlDbType.Int).Value       = jobDuration;
                    cmd.Parameters.Add("@param9", System.Data.SqlDbType.BigInt).Value    = JobModel.GetLSpan(eDate);
                    cmd.Parameters.Add("@param10", System.Data.SqlDbType.BigInt).Value   = 0;
                    cmd.Parameters.Add("@param11", System.Data.SqlDbType.BigInt).Value   = 0;
                    cmd.Parameters.Add("@param12", System.Data.SqlDbType.BigInt).Value   = 0;
                    cmd.Parameters.Add("@param13", System.Data.SqlDbType.BigInt).Value   = 0;
                    cmd.Parameters.Add("@param14", System.Data.SqlDbType.Int).Value      = jobModel.DailyProd;
                    cmd.Parameters.Add("@param15", System.Data.SqlDbType.Int).Value      = 0;
                    cmd.Parameters.Add("@param16", System.Data.SqlDbType.Int).Value      = 0;
                    cmd.Parameters.Add("@param17", System.Data.SqlDbType.Int).Value      = 0;
                    cmd.Parameters.Add("@param18", System.Data.SqlDbType.BigInt).Value   = 0;
                    cmd.Parameters.Add("@param19", System.Data.SqlDbType.BigInt).Value   = 0;
                    cmd.Parameters.Add("@param20", System.Data.SqlDbType.Bit).Value      = false;
                    cmd.Parameters.Add("@param21", System.Data.SqlDbType.Int).Value      = 0;
                    cmd.Parameters.Add("@param22", System.Data.SqlDbType.Bit).Value      = false;
                    cmd.Parameters.Add("@param23", System.Data.SqlDbType.Float).Value    = jobModel.ArtPrice;
                    cmd.Parameters.Add("@param24", System.Data.SqlDbType.Bit).Value      = false;
                    cmd.Parameters.Add("@param25", System.Data.SqlDbType.Bit).Value      = false;
                    cmd.Parameters.Add("@param26", System.Data.SqlDbType.BigInt).Value   = 0;
                    cmd.Parameters.Add("@param27", System.Data.SqlDbType.BigInt).Value   = 0;
                    cmd.Parameters.Add("@param28", System.Data.SqlDbType.Bit).Value      = false;
                    cmd.Parameters.Add("@param29", System.Data.SqlDbType.Bit).Value      = false;
                    cmd.Parameters.Add("@param30", System.Data.SqlDbType.NVarChar).Value = Workflow.TargetDepartment;

                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                }

                Config.InsertOperationLog("manual_splitting", Workflow.TargetOrder + "-" + cbCommLinea.Text + "-" + Workflow.TargetDepartment, "splitorder");

                var c = new Central();
                c.GetBase();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }