Пример #1
0
        public void RefreshCBox()
        {
            switch (YearSource)
            {
            case YearsOf.Components:
                ListHelper.FillMetroCombo(mcboYear, combal.GetAll().Select(i => new { i.YEARUSED }).Distinct().OrderByDescending(m => m.YEARUSED).Where(i => i.YEARUSED != UserSettings.LogInYear && i.YEARUSED < UserSettings.LogInYear).ToList(), "YEARUSED", "YEARUSED");
                break;

            case YearsOf.MaintainanceTable:
                switch (YearofMaintenanceTable_Sub)
                {
                case MaintainanceTableSub.PlasticInjection:
                    ListHelper.FillMetroCombo(mcboYear, pibal.GetAll().Select(i => new { i.YEARUSED }).Distinct().OrderByDescending(m => m.YEARUSED).Where(i => i.YEARUSED != UserSettings.LogInYear && i.YEARUSED < UserSettings.LogInYear).ToList(), "YEARUSED", "YEARUSED");
                    break;

                case MaintainanceTableSub.VacuumPlating:
                    ListHelper.FillMetroCombo(mcboYear, vpbal.GetAll().Select(i => new { i.YEARUSED }).Distinct().OrderByDescending(m => m.YEARUSED).Where(i => i.YEARUSED != UserSettings.LogInYear && i.YEARUSED < UserSettings.LogInYear).ToList(), "YEARUSED", "YEARUSED");
                    break;

                case MaintainanceTableSub.Assembly:
                    ListHelper.FillMetroCombo(mcboYear, assybal.GetAll().Select(i => new { i.YEARUSED }).Distinct().OrderByDescending(m => m.YEARUSED).Where(i => i.YEARUSED != UserSettings.LogInYear && i.YEARUSED < UserSettings.LogInYear).ToList(), "YEARUSED", "YEARUSED");
                    break;
                }
                break;

            case YearsOf.ProcessSetup:
                ListHelper.FillMetroCombo(mcboYear, procbal.GetAll().Select(i => new { i.YEARUSED }).Distinct().OrderByDescending(m => m.YEARUSED).Where(i => i.YEARUSED != UserSettings.LogInYear && i.YEARUSED < UserSettings.LogInYear).ToList(), "YEARUSED", "YEARUSED");
                break;

            case YearsOf.Items:
                ListHelper.FillMetroCombo(mcboYear, itmbal.GetAll().Select(i => new { i.YEARUSED }).Distinct().OrderByDescending(m => m.YEARUSED).Where(i => i.YEARUSED != UserSettings.LogInYear && i.YEARUSED < UserSettings.LogInYear).ToList(), "YEARUSED", "YEARUSED");
                break;
            }
        }
Пример #2
0
        private void Init_Form()
        {
            try
            {
                var strheader = "Component";
                switch (MyState)
                {
                case FormState.Add:
                    LockFields(false);
                    strheader += " - New";
                    break;

                case FormState.Edit:
                case FormState.View:
                    tbl_000_H_PART currcom = new tbl_000_H_PART();
                    currcom             = combal.GetAll().Where(i => i.YEARUSED == yearused && i.PartNo == partno).FirstOrDefault();
                    mlblLastUpdate.Text = currcom.UpdatedDate.ToString();
                    AssignRecord(false);
                    LockFields(false);
                    if (MyState == FormState.View)
                    {
                        LockFields(true);
                        mbtnSave.Text = "Edit";
                        strheader    += " - View";
                        mbtnSave.Focus();
                    }

                    else
                    {
                        mtxtPartNo.ReadOnly = true;
                        mbtnSave.Text       = "Update";
                        strheader          += " - Edit";
                    }
                    break;
                }
                this.Text = strheader;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
        private void Import()
        {
            List <tbl_000_H_PART>  write_list_com;
            List <tbl_000_H_PI>    write_list_pi;
            List <tbl_000_H_VP>    write_list_vp;
            List <tbl_000_H_ASSY>  write_list_assy;
            List <tbl_000_PROCESS> write_list_proc;

            try
            {
                GetExclData(mtxtFilePath.Text);

                if (!mcbOverWrite.Checked)
                {
                    msg = "This process will import previous components from the selected year to the current logged in year. Do you want to continue?";
                    if (MessageHelpers.ShowQuestion(msg) == DialogResult.Yes)
                    {
                        switch (YearSource)
                        {
                            #region Components to Import
                        case YearsOf.Components:
                            write_list_com = new List <tbl_000_H_PART>();
                            var currentyear_list_com = combal.GetByYear(UserSettings.LogInYear).ToList();
                            //Matching by 'PartNo' or 'PartName'
                            foreach (tbl_000_H_PART c in currentyear_list_com)
                            {
                                write_list_com.Add(combal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.PartNo == c.PartNo || w.PartName == c.PartName)).FirstOrDefault());
                            }
                            //Remove columns from excell if it exists in current year
                            foreach (tbl_000_H_PART c in write_list_com)
                            {
                                if (c != null)
                                {
                                    comlist.RemoveAll(r => r.PartNo == c.PartNo || r.PartName == c.PartName);
                                }
                            }
                            //Fill some Columns and Save them
                            Save_com();
                            break;

                            #endregion
                            #region Tabulation to Import
                        case YearsOf.MaintainanceTable:
                            switch (YearofMaintenanceTable_Sub)
                            {
                            case MaintainanceTableSub.PlasticInjection:
                                write_list_pi = new List <tbl_000_H_PI>();
                                var currentyear_list_pi = pibal.GetByYear(UserSettings.LogInYear).ToList();
                                foreach (tbl_000_H_PI p in currentyear_list_pi)
                                {
                                    write_list_pi.Add(pibal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.MoldNo == p.MoldNo || w.MoldName == p.MoldName)).FirstOrDefault());
                                }
                                foreach (tbl_000_H_PI p in write_list_pi)
                                {
                                    if (p != null)
                                    {
                                        pilist.RemoveAll(r => r.MoldNo == p.MoldNo || r.MoldName == p.MoldName);
                                    }
                                }
                                Save_pi();
                                break;

                            case MaintainanceTableSub.VacuumPlating:
                                write_list_vp = new List <tbl_000_H_VP>();
                                var currentyear_list_vp = vpbal.GetByYear(UserSettings.LogInYear).ToList();
                                foreach (tbl_000_H_VP v in currentyear_list_vp)
                                {
                                    write_list_vp.Add(vpbal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.PartNo == v.PartNo || w.PartName == v.PartName)).FirstOrDefault());
                                }
                                foreach (tbl_000_H_VP v in write_list_vp)
                                {
                                    if (v != null)
                                    {
                                        vplist.RemoveAll(r => r.PartNo == v.PartNo || r.PartName == v.PartName);
                                    }
                                }
                                Save_vp();
                                break;

                            case MaintainanceTableSub.Assembly:
                                write_list_assy = new List <tbl_000_H_ASSY>();
                                var currentyear_list_assy = assybal.GetByYear(UserSettings.LogInYear).ToList();
                                foreach (tbl_000_H_ASSY a in currentyear_list_assy)
                                {
                                    write_list_assy.Add(assybal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.PartNo == a.PartNo || w.PartName == a.PartName)).FirstOrDefault());
                                }
                                foreach (tbl_000_H_ASSY a in write_list_assy)
                                {
                                    if (a != null)
                                    {
                                        assylist.RemoveAll(r => r.PartNo == a.PartNo || r.PartName == a.PartName);
                                    }
                                }
                                Save_assy();
                                break;
                            }
                            break;

                            #endregion
                            #region Process to Import
                        case YearsOf.ProcessSetup:
                            write_list_proc = new List <tbl_000_PROCESS>();
                            var currentyear_list_proc = procbal.GetByYear(UserSettings.LogInYear).ToList();
                            foreach (tbl_000_PROCESS p in currentyear_list_proc)
                            {
                                write_list_proc.Add(procbal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.SubProcessCode == p.SubProcessCode || w.ItemDescription == p.ItemDescription)).FirstOrDefault());
                            }
                            foreach (tbl_000_PROCESS p in write_list_proc)
                            {
                                if (p != null)
                                {
                                    proclist.RemoveAll(r => r.SubProcessCode == p.SubProcessCode || r.ItemDescription == p.ItemDescription);
                                }
                            }
                            Save_proc();
                            break;
                            #endregion
                        }
                    }
                }
                else
                {
                    msg = "This process will remove the existing components and replace it with the selected year. Do you want to continue?";
                    if (MessageHelpers.ShowQuestion(msg) == DialogResult.Yes)
                    {
                        switch (YearSource)
                        {
                            #region Components to Import with Overwrite
                        case YearsOf.Components:
                            write_list_com = new List <tbl_000_H_PART>();
                            //Matching by 'PartNo' or 'PartName'
                            foreach (tbl_000_H_PART c in comlist)
                            {
                                write_list_com.Add(combal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.PartNo == c.PartNo || w.PartName == c.PartName)).FirstOrDefault());
                            }
                            //Delete the records to be Overwritten
                            if (BPSUtilitiesV1.NZ(write_list_com, "").ToString() != "")
                            {
                                foreach (tbl_000_H_PART c in write_list_com)
                                {
                                    if (c != null)
                                    {
                                        combal.Delete(c);
                                    }
                                }
                            }
                            //Fill some Columns and Save them
                            Save_com();
                            break;

                            #endregion
                            #region Tabulation to import with Overwrite
                        case YearsOf.MaintainanceTable:
                            switch (YearofMaintenanceTable_Sub)
                            {
                            case MaintainanceTableSub.PlasticInjection:
                                write_list_pi = new List <tbl_000_H_PI>();
                                foreach (tbl_000_H_PI p in pilist)
                                {
                                    write_list_pi.Add(pibal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.MoldNo == p.MoldNo || w.MoldName == p.MoldName)).FirstOrDefault());
                                }
                                if (BPSUtilitiesV1.NZ(write_list_pi, "").ToString() != "")
                                {
                                    foreach (tbl_000_H_PI p in write_list_pi)
                                    {
                                        if (p != null)
                                        {
                                            pibal.Delete(p);
                                        }
                                    }
                                }
                                Save_pi();
                                break;

                            case MaintainanceTableSub.VacuumPlating:
                                write_list_vp = new List <tbl_000_H_VP>();
                                foreach (tbl_000_H_VP v in vplist)
                                {
                                    write_list_vp.Add(vpbal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.PartNo == v.PartNo || w.PartName == v.PartName)).FirstOrDefault());
                                }
                                if (BPSUtilitiesV1.NZ(write_list_vp, "").ToString() != "")
                                {
                                    foreach (tbl_000_H_VP v in write_list_vp)
                                    {
                                        if (v != null)
                                        {
                                            vpbal.Delete(v);
                                        }
                                    }
                                }
                                Save_vp();
                                break;

                            case MaintainanceTableSub.Assembly:
                                write_list_assy = new List <tbl_000_H_ASSY>();
                                foreach (tbl_000_H_ASSY a in assylist)
                                {
                                    write_list_assy.Add(assybal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.PartNo == a.PartNo || w.PartName == a.PartName)).FirstOrDefault());
                                }
                                if (BPSUtilitiesV1.NZ(write_list_assy, "").ToString() != "")
                                {
                                    foreach (tbl_000_H_ASSY a in write_list_assy)
                                    {
                                        if (a != null)
                                        {
                                            assybal.Delete(a);
                                        }
                                    }
                                }
                                Save_assy();
                                break;
                            }
                            break;

                            #endregion
                            #region Process to Import with Overwrite
                        case YearsOf.ProcessSetup:
                            write_list_proc = new List <tbl_000_PROCESS>();
                            List <tbl_000_PROCESS> todelete_proc = new List <tbl_000_PROCESS>();
                            foreach (tbl_000_PROCESS p in proclist)
                            {
                                write_list_proc.Add(procbal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.SubProcessCode == p.SubProcessCode || w.ItemDescription == p.ItemDescription)).FirstOrDefault());
                            }
                            if (BPSUtilitiesV1.NZ(write_list_proc, "").ToString() != "")
                            {
                                foreach (tbl_000_PROCESS p in write_list_proc)
                                {
                                    if (p != null)
                                    {
                                        todelete_proc.Add(p);
                                    }
                                }
                                procbal.Delete(todelete_proc);
                            }
                            Save_proc();
                            break;
                            #endregion
                        }
                    }
                }
                this.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        public void RefreshGrid()
        {
            try
            {
                switch (KindOfList)
                {
                    #region Materials/ Compo
                case "CL":
                    var list_CL = combal.GetAll().Select(i => new
                    {
                        i.DocID,
                        i.YEARUSED,
                        Part_No       = i.PartNo,
                        Name          = i.PartName,
                        Whddd_Qty     = i.WholeQty,
                        Whddd_Unit    = i.WholeUnit,
                        Conddd_Qty    = i.ConversionQty,
                        Conddd_Unit   = i.ConversionUnit,
                        Whddd_Price   = i.WholePrice,
                        Conddd_Price  = i.ConversionPrice,
                        Prevddd_Price = i.PreviousPrice,
                        Locked        = i.IsLocked,
                    }
                                                         ).OrderBy(m => m.DocID).Where(r => r.YEARUSED == UserSettings.LogInYear).ToList();
                    this.mgridList.DataSource = list_CL;
                    break;

                    #endregion
                    #region Plastic Injection
                case "MT_PI":
                    var list_PI = pibal.GetAll().Select(i => new
                    {
                        i.DocID,
                        i.YEARUSED,
                        Mold_No   = i.MoldNo,
                        Mold_Name = i.MoldName,
                        i.Oz,
                        Purge_Per_Gram  = i.PurgePerG,
                        Shots_Per_Hour  = i.SPH,
                        Cavity          = i.Cavity,
                        Pieces_Per_Hour = i.PPH,
                    }).OrderBy(m => m.DocID).Where(r => r.YEARUSED == UserSettings.LogInYear).ToList();
                    mgridList.DataSource = list_PI;
                    break;

                    #endregion
                    #region Vacuum Plating
                case "MT_VP":
                    var list_VP = vpbal.GetAll().Select(i => new
                    {
                        DocID       = i.DocID,
                        YEARUSED    = i.YEARUSED,
                        Part_No     = i.PartNo,
                        Part_Name   = i.PartName,
                        Source_Data = i.SourceData,
                    }).OrderBy(m => m.DocID).Where(r => r.YEARUSED == UserSettings.LogInYear).ToList();
                    mgridList.DataSource = list_VP;
                    break;

                    #endregion
                    #region Assymbly
                case "MT_ASSY":
                    var list_ASSY = assybal.GetAll().Select(i => new
                    {
                        DocID         = i.DocID,
                        YEARUSED      = i.YEARUSED,
                        Part_No       = i.PartNo,
                        Part_Name     = i.PartName,
                        Rate_Per_Hour = i.RATEPERHOUR,
                    }).OrderBy(m => m.DocID).Where(r => r.YEARUSED == UserSettings.LogInYear).ToList();
                    mgridList.DataSource = list_ASSY;
                    break;

                    #endregion
                    #region MPT
                case "MPT":
                    var list_MR = mrbal.GetAll().Select(i => new
                    {
                        Code        = i.SectionCode,
                        Description = i.Description,
                        Time        = i.Time,
                        Active      = i.IsActive,
                        IsCosting   = i.IsCosting
                    }).Distinct().OrderBy(m => m.Code).ToList();
                    this.mgridList.DataSource = list_MR;
                    break;

                    #endregion
                    #region Items
                case "ITEM":
                    int yeartouse = UserSettings.LogInYear;
                    if (IsPrevious)
                    {
                        yeartouse = PreviousYear;
                    }
                    var list_ITEM = itembal.GetAll().Select(i => new
                    {
                        i.DocID,
                        i.YEARUSED,
                        i.ItemNo,
                        i.Description,
                        i.IsLocked
                    }).Where(w => w.YEARUSED == yeartouse).Distinct().OrderBy(m => m.Description).ToList();
                    DataTable itmTable = new DataTable();
                    using (var reader = ObjectReader.Create(list_ITEM,
                                                            "DocID",
                                                            "YEARUSED",
                                                            "ItemNo",
                                                            "Description",
                                                            "IsLocked"))
                    {
                        itmTable.Load(reader);
                        mgridList.DataSource = itmTable;
                    }
                    break;

                    #endregion
                    #region
                case "CAT":
                    var list_CAT = catbal.GetAll().Select(i => new
                    {
                        DocID = i.RecID,
                        i.YEARUSED,
                        Code        = i.CATCODE,
                        Description = i.CATDESC
                    }).Where(w => w.YEARUSED == PreviousYear).Distinct().OrderBy(m => m.Code).ToList();
                    DataTable catTable = new DataTable();
                    using (var reader = ObjectReader.Create(list_CAT,
                                                            "DocID",
                                                            "YEARUSED",
                                                            "Code",
                                                            "Description"))
                    {
                        catTable.Load(reader);
                        mgridList.DataSource = catTable;
                    }
                    break;
                    #endregion
                }
                ColumnManager();
            }
            catch (Exception ex)
            {
                MessageHelpers.ShowError(ex.Message);
            }
        }