Example #1
0
        public void loadArchieve(long pDetailId)
        {
            var a     = new RsafDbContext();
            var query =
                from c in a.RSAF_ARCHIVE
                where c.DETAIL_ID == pDetailId
                select c;

            foreach (var row in query)
            {
                this.TxANSPSI.Text = row.ANSPSI;
                if (row.ANSPSIDT != null)
                {
                    this.DtANSPSIDT.Value = DateTime.Parse(row.ANSPSIDT.Value.ToShortDateString());
                }
                this.TxANSRVREF.Text = row.ANSRVREF;
                if (row.DESPARDT != null)
                {
                    this.DtDESPARDT.Value = DateTime.Parse(row.DESPARDT.Value.ToShortDateString());
                }
                this.TxDESPPART.Text = row.DESPPART;
                if (row.INTOROS != null)
                {
                    this.DtINTOROS.Value = DateTime.Parse(row.INTOROS.Value.ToShortDateString());
                }
                if (row.PROMDATE != null)
                {
                    this.DtPROMDATE.Value = DateTime.Parse(row.PROMDATE.Value.ToShortDateString());
                }
                this.TxRCD.Text    = row.RCD.ToString();
                this.TxRECDOC.Text = row.RECDOC;
                if (row.RECDPART != null)
                {
                    this.DtRECDPART.Value = DateTime.Parse(row.RECDPART.Value.ToShortDateString());
                }
                this.TxACC_DM.Text      = row.ACC_DM.ToString();
                this.TxREF.Text         = row.REF;
                this.TxRVREF.Text       = row.RVREF;
                this.TxSCRPREF.Text     = row.SCRPREF;
                this.TxX.Text           = row.X.ToString();
                this.TxDESCRIPTION.Text = row.DESCRIPTION;
                if (row.PREVIOUS_PROMISE_DATE != null)
                {
                    this.DtPREVIOUS_PROMISE_DATE.Value = DateTime.Parse(row.PREVIOUS_PROMISE_DATE.Value.ToShortDateString());
                }
            }
            a.Dispose();
        }
Example #2
0
        public POMasterForm(PODetailForm detailForm)
        {
            InitializeComponent();
            DetailForm = detailForm;
            List <RSAF_TYPE> listType = new List <RSAF_TYPE>();
            var a = new RsafDbContext();

            listType = a.RSAF_TYPE.ToList();
            a.Dispose();
            CxTYPE.DataSource    = listType;
            CxTYPE.DisplayMember = "TYPE";
            CxTYPE.ValueMember   = "TYPE_CODE";

            List <RSAF_SITE> listSite = new List <RSAF_SITE>();
            var b = new RsafDbContext();

            listSite = b.RSAF_SITE.ToList();
            b.Dispose();
            CxSITE.DataSource    = listSite;
            CxSITE.DisplayMember = "SITE";
            CxSITE.ValueMember   = "SITE_CODE";
        }
Example #3
0
        private void ArrangeFields()
        {
            SearchFields x = CxSearchField.SelectedItem as SearchFields;

            List <SearchCriterias> textCriteria = new List <SearchCriterias>();

            textCriteria.Add(new SearchCriterias()
            {
                Id = "E", Name = "Equals"
            });
            textCriteria.Add(new SearchCriterias()
            {
                Id = "C", Name = "Contains"
            });
            List <SearchCriterias> otherCriteria = new List <SearchCriterias>();

            otherCriteria.Add(new SearchCriterias()
            {
                Id = "E", Name = "Equals"
            });

            TxValue.Text    = "";
            CbValue.Checked = false;


            switch (x.ValueType)
            {
            case ValueTypes.Text:
                CbValue.Visible                = false;
                CxValue.Visible                = false;
                DtValue.Visible                = false;
                TxValue.Visible                = true;
                CxSearchCriteria.DataSource    = textCriteria;
                CxSearchCriteria.ValueMember   = "Id";
                CxSearchCriteria.DisplayMember = "Name";
                break;

            case ValueTypes.CheckBox:
                CbValue.Visible                = true;
                CxValue.Visible                = false;
                DtValue.Visible                = false;
                TxValue.Visible                = false;
                CxSearchCriteria.DataSource    = otherCriteria;
                CxSearchCriteria.ValueMember   = "Id";
                CxSearchCriteria.DisplayMember = "Name";
                break;

            case ValueTypes.ComboBox:
                CbValue.Visible                = false;
                CxValue.Visible                = true;
                DtValue.Visible                = false;
                TxValue.Visible                = false;
                CxSearchCriteria.DataSource    = otherCriteria;
                CxSearchCriteria.ValueMember   = "Id";
                CxSearchCriteria.DisplayMember = "Name";
                switch (x.Id)
                {
                case "TYPE":
                    List <RSAF_TYPE> listType = new List <RSAF_TYPE>();
                    var a = new RsafDbContext();
                    listType = a.RSAF_TYPE.ToList();
                    a.Dispose();
                    CxValue.DataSource    = listType;
                    CxValue.DisplayMember = "TYPE";
                    CxValue.ValueMember   = "TYPE_CODE";
                    break;

                case "SITE":
                    List <RSAF_SITE> listSite = new List <RSAF_SITE>();
                    var b = new RsafDbContext();
                    listSite = b.RSAF_SITE.ToList();
                    b.Dispose();
                    CxValue.DataSource    = listSite;
                    CxValue.DisplayMember = "SITE";
                    CxValue.ValueMember   = "SITE_CODE";
                    break;
                }
                break;

            case ValueTypes.DateTime:
                CbValue.Visible                = false;
                CxValue.Visible                = false;
                DtValue.Visible                = true;
                DtValue.CustomFormat           = "dd/MM/yyyy";
                TxValue.Visible                = false;
                CxSearchCriteria.DataSource    = otherCriteria;
                CxSearchCriteria.ValueMember   = "Id";
                CxSearchCriteria.DisplayMember = "Name";
                break;
            }
        }
Example #4
0
        private void BtUpdate_Click(object sender, EventArgs e)
        {
            if (TxBAEPART.Text != "" && TxBAEPO.Text != "" && CxSITE.SelectedIndex != -1 && CxTYPE.SelectedIndex != -1)
            {
                ///////////////////////////////
                ///
                /// SAVE CHANGES
                ///
                ///////////////////////////////
                if (DetailForm.TxBAEPART.Text == this.TxBAEPART.Text &&
                    DetailForm.TxBAEPO.Text == this.TxBAEPO.Text &&
                    DetailForm.CxSITE.SelectedIndex == this.CxSITE.SelectedIndex &&
                    DetailForm.CxTYPE.SelectedIndex == this.CxTYPE.SelectedIndex)
                {
                    MessageBox.Show("There is no change!", "Information");
                }
                else
                {
                    DialogResult dialogResult = MessageBox.Show("Are you sure to change the PO header values?", "Confirm PO Header Changes", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        long newmasterId           = 0;
                        List <RSAF_MASTER> lMaster = new List <RSAF_MASTER>();
                        var b = new RsafDbContext();
                        lMaster = b.RSAF_MASTER.Where(c => c.BAEPART == this.TxBAEPART.Text.ToString() &&
                                                      c.BAEPO == this.TxBAEPO.Text.ToString() &&
                                                      c.SITE == this.CxSITE.SelectedValue.ToString() &&
                                                      c.TYPE == this.CxTYPE.SelectedValue.ToString()).ToList();

                        if (lMaster != null)
                        {
                            foreach (var x in lMaster)
                            {
                                newmasterId = lMaster.First().MASTER_ID;
                            }
                        }
                        b.Dispose();

                        if (newmasterId == 0)
                        {
                            var a        = new RsafDbContext();
                            var masterPO = a.RSAF_MASTER.Find(masterId);

                            if (DetailForm.TxBAEPART.Text != this.TxBAEPART.Text)
                            {
                                masterPO.BAEPART = this.TxBAEPART.Text;
                            }

                            if (DetailForm.TxBAEPO.Text != this.TxBAEPO.Text)
                            {
                                masterPO.BAEPO = this.TxBAEPO.Text;
                            }

                            if (DetailForm.CxSITE.SelectedIndex != this.CxSITE.SelectedIndex)
                            {
                                masterPO.SITE = this.CxSITE.SelectedValue.ToString();
                            }

                            if (DetailForm.CxTYPE.SelectedIndex != this.CxTYPE.SelectedIndex)
                            {
                                masterPO.TYPE = this.CxTYPE.SelectedValue.ToString();
                            }

                            a.SaveChanges();
                            a.Dispose();

                            DetailForm.TxBAEPART.Text       = this.TxBAEPART.Text;
                            DetailForm.TxBAEPO.Text         = this.TxBAEPO.Text;
                            DetailForm.CxSITE.SelectedIndex = this.CxSITE.SelectedIndex;
                            DetailForm.CxTYPE.SelectedIndex = this.CxTYPE.SelectedIndex;

                            MessageBox.Show("PO header has been successfully updated!", "Information");
                            DetailForm.toolStripStatusLabel.Text = "Changed Purchase Order Header";
                            Close();
                        }
                        else
                        {
                            MessageBox.Show("PO header could not updated because there is already a PO which has the same header values. Check them first, please!", "Error");
                        }
                    }
                }
            }
        }