Ejemplo n.º 1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            //Store.Default.suggestData = cbSuggest.Checked;
            Store.Default.autoSync     = cbAutoSync.Checked;
            Store.Default.backupData   = cbBackupData.Checked;
            Store.Default.fastStart    = cbFast.Checked;
            Store.Default.daysToFinish = Convert.ToInt32(npdComplet.Value);

            UpdateDepartmentHours();

            Store.Default.downloadSource     = txtDownloadSource.Text;
            Store.Default.updateCheckRuntime = cbUpdateRuntime.Checked;

            Store.Default.Save();

            SaveDepartments();
            SaveProductionEff();
            var c = new Central();

            c.GetBase();
            c.GetProductionColor();

            var table = Central.TaskList;

            dataGridView2.DataSource = table;
        }
Ejemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            for (var i = DateTime.Now.Year - 2; i <= DateTime.Now.Year + 1; i++)
            {
                cboYears.Items.Add(i);
            }

            cboMonth.SelectedIndexChanged += (s, ev) =>
            {
                if (_firstRead)
                {
                    return;
                }

                Month = cboMonth.SelectedIndex + 1;
                LoadData();
            };

            cboYears.SelectedIndexChanged += (s, ev) =>
            {
                if (_firstRead)
                {
                    return;
                }

                Year = Convert.ToInt32(cboYears.Text);
                LoadData();
            };

            foreach (var str in Store.Default.arrDept.Split(','))
            {
                if (!string.IsNullOrEmpty(str))
                {
                    cboDepartment.Items.Add(str);
                }
            }

            if (cboDepartment.Items.Count > 0)
            {
                cboDepartment.SelectedIndex = 0;
            }

            cboYears.SelectedIndex = cboYears.FindString(DateTime.Now.Year.ToString());
            cboMonth.SelectedIndex = DateTime.Now.Month - 1;

            LoadData();

            FormClosing += delegate
            {
                lblSavedInfo.Visible = true;
                lblSavedInfo.Text    = "Reloading...";

                var m = new Central();
                m.GetBase();
            };

            base.OnLoad(e);
        }
Ejemplo n.º 3
0
        private bool FractionateOrders()
        {
            int.TryParse(txtQty.Text, out var newQty);
            int.TryParse(txtPersons.Text, out var newMembers);

            var operation = cbOperation.Text;

            if (newQty <= 0 || newMembers <= 0)
            {
                MessageBox.Show("Invalid qty or members input.");
                return(false);
            }

            if (newQty < 0 || newQty > _bar.LoadedQty - _bar.ProductionQty)
            {
                MessageBox.Show("Value must be between 0 and maximum qty by 'commessa'");
                return(false);
            }

            if (_bar.ProductionQty == 0 && newQty == _bar.LoadedQty)
            {
                MessageBox.Show("You are fractionating Total Quantity,\nyou should delete the order and reprogram.");
                //DeleteExsistingOrder();
                //InsertFractionatedOrder(newQty, newMembers);
            }
            else
            {
                UpdateExsistingOrder(_bar.LoadedQty - newQty, 0, "", _bar.FromTime);
                InsertFractionatedOrder(newQty, newMembers);
            }

            var queryOn = $"{_bar.RowText}-{cboLine.Text}-{_bar.Department}";

            Config.InsertOperationLog("manual_fractioning", queryOn, "fractionate");

            var c = new Central();

            c.GetBase();

            return(true);
        }
Ejemplo n.º 4
0
        private void PbCloseOrder_Click(object sender, EventArgs e)
        {
            if (Workflow.TargetClosedByUser)
            {
                var dr = MessageBox.Show("Are you sure you want to recover this order?", "Workflow controller", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (dr == DialogResult.Yes)
                {
                    using (var ctx = new System.Data.Linq.DataContext(Central.SpecialConnStr))
                    {
                        ctx.ExecuteCommand("update objects set closedord='false' where ordername={0} and aim={1} and department={2}",
                                           Workflow.TargetOrder, Workflow.TargetLine, Workflow.TargetDepartment);
                    }
                    var c = new Central();
                    c.GetBase();

                    Close();
                }
            }
            else
            {
                var dr = MessageBox.Show("Are you sure you want to close this order?", "Workflow controller", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (dr == DialogResult.Yes)
                {
                    using (var ctx = new System.Data.Linq.DataContext(Central.SpecialConnStr))
                    {
                        ctx.ExecuteCommand("update objects set closedord='true' where ordername={0} and aim={1}",
                                           Workflow.TargetOrder, Workflow.TargetLine);
                    }
                    var c = new Central();
                    c.GetBase();

                    Close();
                }
            }
        }
Ejemplo n.º 5
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();
            }
        }
Ejemplo n.º 6
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);
            }
        }