Ejemplo n.º 1
0
        public FrmConsumables(MasterConsumable consum, Form mdiparent)
        {
            this._consum    = consum;
            this._mdiparent = mdiparent;

            InitializeComponent();

            lqtToolStrip1.SaveAndCloseClick += new EventHandler(lqtToolStrip1_SaveAndCloseClick);
            lqtToolStrip1.SaveAndNewClick   += new EventHandler(lqtToolStrip1_SaveAndNewClick);

            this.EnableSaveButton  += new EventHandler(FrmConsumables_EnableSaveButton);
            this.DisableSaveButton += new EventHandler(FrmConsumables_DisableSaveButton);
            OnDataUsageEdit        += new EventHandler(_taPane_OnDataUsageEdit);
            lsvProductUsageT.AddNoneEditableColumn(0);
            lsvProductUsageT.AddNoneEditableColumn(1);
            lsvProductUsageP.AddNoneEditableColumn(0);
            lsvProductUsageP.AddNoneEditableColumn(1);
            lsvProductUsageI.AddNoneEditableColumn(0);
            lsvProductUsageI.AddNoneEditableColumn(1);
            lsvProductUsageT.SubitemTextChanged += new EventHandler <SubitemTextEventArgs>(lsvProductUsage_SelectedIndexChanged);
            lsvProductUsageP.SubitemTextChanged += new EventHandler <SubitemTextEventArgs>(lsvProductUsageP_SelectedIndexChanged);
            lsvProductUsageI.SubitemTextChanged += new EventHandler <SubitemTextEventArgs>(lsvProductUsageI_SelectedIndexChanged);
            PopTestingAreas();
            PopTest();
            PopInstrument();
            PopPeriod();
            PopProduct();
            LoadTestCtr();
        }
Ejemplo n.º 2
0
        void lqtToolStrip1_SaveAndNewClick(object sender, EventArgs e)
        {
            try
            {
                LQTUserMessage msg = SaveOrUpdateObject();
                ((LqtMainWindowForm)_mdiparent).ShowStatusBarInfo(msg.Message, true);

                TestingArea ta = _consum.TestingArea;
                Test        t  = _consum.Test;

                _consum             = new MasterConsumable();
                _consum.TestingArea = ta;
                _consum.Test        = t;

                // LoadTestCtr();
                SetControlState();
                comTest.Enabled     = true;
                comTestarea.Enabled = true;

                _isedited = false;
            }
            catch (Exception ex)
            {
                new FrmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
Ejemplo n.º 3
0
 private void PopMasterConsumable()
 {
     if (_test.Id > 0)
     {
         _consum = DataRepository.GetConsumableByTestandArea(_test.Id, _test.TestingArea.Id);
     }
     if (_consum == null)
     {
         _consum = new MasterConsumable();
     }
 }
Ejemplo n.º 4
0
        private void SetConsControlState()
        {
            this.txtNoofTest.Text = "0";

            PopConsInstrument();
            PopConsProduct();
            PopConsPeriod();
            _consum = new MasterConsumable();
            BindProductUsageT();
            BindProductUsageP();
            BindProductUsageI();
        }
Ejemplo n.º 5
0
        private void SaveConsumable(string impCons)
        {
            Test impTest = DataRepository.GetTestByName(impCons);

            if (!_listOfImportedConsumable.ContainsKey(impTest.TestName))
            {
                if (DataRepository.GetConsumableByName(impTest.TestName) == null)
                {
                    MasterConsumable con = new MasterConsumable();
                    con.Test        = impTest;
                    con.TestingArea = impTest.TestingArea;
                    DataRepository.SaveOrUpdateConsumables(con);
                }
            }
        }
Ejemplo n.º 6
0
        private IList <ImportProUsageData> GetDataRow(DataSet ds)
        {
            string           testName;
            string           insName;
            string           proName;
            string           period;
            int              noOfTest;
            decimal          rate;
            string           tName           = "";
            string           iName           = "";
            bool             isForTest       = false;
            bool             isForPeriod     = false;
            bool             isForInstrument = false;
            MasterConsumable cons            = null;
            Test             test            = null;
            Instrument       instrument      = null;
            bool             isnew           = false;

            int  rowno = 0;
            bool haserror;

            IList <ImportProUsageData> rdlist = new List <ImportProUsageData>();
            List <string> con = new List <string>();


            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                rowno++;
                haserror = false;

                testName = Convert.ToString(dr[0]).Trim();   //region name
                insName  = Convert.ToString(dr[1]).Trim();
                proName  = Convert.ToString(dr[2]).Trim();
                period   = Convert.ToString(dr[3]).Trim();
                try
                {
                    noOfTest = int.Parse(Convert.ToString(dr[4]));
                }
                catch
                {
                    noOfTest = 0;
                }
                try
                {
                    rate = decimal.Parse(Convert.ToString(dr[5]));
                }
                catch
                {
                    rate = 1;
                }
                try { isForTest = Convert.ToBoolean(int.Parse(Convert.ToString(dr[6]))); }
                catch { isForTest = false; }
                try { isForPeriod = Convert.ToBoolean(int.Parse(Convert.ToString(dr[7]))); }
                catch { isForPeriod = false; }
                try { isForInstrument = Convert.ToBoolean(int.Parse(Convert.ToString(dr[8]))); }
                catch { isForInstrument = false; }

                ImportProUsageData rd = new ImportProUsageData(testName, insName, proName, period, noOfTest, rate, isForTest, isForPeriod, isForInstrument, rowno);

                if (!string.IsNullOrEmpty(Convert.ToString(dr[0])))
                {
                    SaveConsumable(Convert.ToString(dr[0]));
                }


                if (tName != testName)
                {
                    if (!string.IsNullOrEmpty(testName))
                    {
                        test = DataRepository.GetTestByName(testName);
                    }
                    else
                    {
                        test = null;
                    }
                    tName = testName;
                }

                if (test != null)
                {
                    // rd.Test = test;
                    cons = DataRepository.GetConsumableByName(testName);

                    rd.Cons = cons;
                    if (iName != insName)
                    {
                        if (!String.IsNullOrEmpty(insName))
                        {
                            instrument = DataRepository.GetInstrumentByName(insName);
                        }
                        else
                        {
                            instrument = null;
                        }
                        iName = insName;
                    }

                    if (instrument != null)
                    {
                        rd.Instrument = instrument;

                        if (!String.IsNullOrEmpty(proName) && !String.IsNullOrEmpty(rd.Period))
                        {
                            rd.Product = DataRepository.GetProductByName(proName);
                            if (rd.Product == null)
                            {
                                haserror = true;
                            }
                            if (!isnew)
                            {
                                if (cons.IsExsistUsageRatePerInst(instrument.Id, rd.Product.Id) && rd.IsForInstrument == true)
                                {
                                    rd.IsExist = true;
                                }
                            }
                        }
                        else
                        {
                            haserror = true;
                        }
                    }
                    // else
                    // haserror = true;
                    if (rd.IsForPeriod == true)
                    {
                        if (!String.IsNullOrEmpty(proName) && !String.IsNullOrEmpty(rd.Period))
                        {
                            rd.Product = DataRepository.GetProductByName(proName);
                            if (rd.Product == null)
                            {
                                haserror = true;
                            }
                            if (!isnew)
                            {
                                if (cons.IsExsistUsageRatePerPeriod(rd.Product.Id))
                                {
                                    rd.IsExist = true;
                                }
                            }
                        }
                        else
                        {
                            haserror = true;
                        }
                    }
                    if (rd.IsForTest == true)
                    {
                        if (!String.IsNullOrEmpty(proName) && rd.NoOfTest > 0)
                        {
                            rd.Product = DataRepository.GetProductByName(proName);
                            if (rd.Product == null)
                            {
                                haserror = true;
                            }
                            if (!isnew)
                            {
                                if (cons.IsExsistUsageRatePerPeriod(rd.Product.Id))
                                {
                                    rd.IsExist = true;
                                }
                            }
                        }
                        else
                        {
                            haserror = true;
                        }
                    }
                }
                else
                {
                    haserror = true;
                }


                rd.HasError = haserror;
                rdlist.Add(rd);
                isnew = false;
            }

            return(rdlist);
        }
Ejemplo n.º 7
0
        public void RebindTest(MasterConsumable consum)
        {
            this._consum = consum;

            BindConsumable();
        }
Ejemplo n.º 8
0
 public static void DeleteConsumable(MasterConsumable masterConsumable)
 {
     DaoFactory.GetDaoFactory().CreateConsumableDao().Delete(masterConsumable);
 }
Ejemplo n.º 9
0
 public static void SaveOrUpdateConsumables(MasterConsumable consum)
 {
     DaoFactory.GetDaoFactory().CreateConsumableDao().SaveOrUpdate(consum);
 }