Esempio n. 1
0
        public object[] queryDataMstDestinationByDestinationId(MST_DESTINATION param)
        {
            log.Info("Start log INFO... queryDataMstDestinationByDestinationId");
            MsgForm         msgError = new MsgForm();
            MST_DESTINATION form     = new MST_DESTINATION();

            try
            {
                using (var db = new PaknampoScaleDBEntities())
                {
                    form = (from row in db.MST_DESTINATION where row.DESTINATION_ID == param.DESTINATION_ID select row).FirstOrDefault();
                    db.Dispose();
                    msgError.statusFlag = MsgForm.STATUS_SUCCESS;
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString(), ex);
                msgError.statusFlag         = MsgForm.STATUS_ERROR;
                msgError.messageDescription = ex.ToString();
            }
            finally
            {
                log.Info("End log INFO... queryDataMstDestinationByDestinationId");
            }
            return(new object[] { msgError, form });
        }
Esempio n. 2
0
        public void resetDataMstDistination()
        {
            txtDistinationId.Text       = "";
            txtDistinationName.Text     = "";
            txtDistinationAddress.Text  = "";
            cboDistricts.SelectedValue  = "";
            cboAmphure.SelectedValue    = "";
            cboProvince.SelectedValue   = "";
            txtDistinationPostcode.Text = "";
            txtDistinationTelNo.Text    = "";
            txtDistinationFax.Text      = "";
            formMstDistination          = new MST_DESTINATION();
            flagAddEdit = "A";
            txtDistinationId.Enabled = true;
            txtDistinationId.Focus();

            lstdataAmphure   = new List <MST_AMPHURES>();
            lstdataDistricts = new List <MST_DISTRICTS>();

            cboAmphure.DataSource    = lstdataAmphure;
            cboAmphure.ValueMember   = "AMPHURE_ID";
            cboAmphure.DisplayMember = "NAME_TH";
            cboAmphure.SelectedValue = "";

            cboDistricts.DataSource    = lstdataDistricts;
            cboDistricts.ValueMember   = "DISTRICT_ID";
            cboDistricts.DisplayMember = "NAME_TH";
            cboDistricts.SelectedValue = "";
        }
Esempio n. 3
0
        public object[] deleteDataMstDestination(MST_DESTINATION param)
        {
            log.Info("Start log INFO... deleteDataMstDestination");
            MsgForm         msgError = new MsgForm();
            MST_DESTINATION form     = new MST_DESTINATION();

            try
            {
                using (var db = new PaknampoScaleDBEntities())
                {
                    form = (from row in db.MST_DESTINATION where row.DESTINATION_ID == param.DESTINATION_ID select row).FirstOrDefault();
                    if (Util.isNotEmpty(form))
                    {
                        db.MST_DESTINATION.Remove(form);
                    }
                    db.SaveChanges();
                    msgError.statusFlag = MsgForm.STATUS_SUCCESS;
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString(), ex);
                msgError.statusFlag         = MsgForm.STATUS_ERROR;
                msgError.messageDescription = ex.ToString();
            }
            finally
            {
                log.Info("End log INFO... deleteDataMstDestination");
            }
            return(new object[] { msgError });
        }
Esempio n. 4
0
        private void cboAmphure_SelectionChangeCommitted(object sender, EventArgs e)
        {
            formMstDistination = new MST_DESTINATION();
            lstdataDistricts   = new List <MST_DISTRICTS>();

            cboDistricts.DataSource    = lstdataDistricts;
            cboDistricts.ValueMember   = "DISTRICT_ID";
            cboDistricts.DisplayMember = "NAME_TH";
            cboDistricts.SelectedValue = "";

            txtDistinationPostcode.Text = "";

            queryComboMstDistricts();
        }
Esempio n. 5
0
        public void queryDataMstDistinationByDestinationId()
        {
            MST004Controller mst004Ctrl = new MST004Controller();

            try
            {
                object[] result = mst004Ctrl.queryDataMstDestinationByDestinationId(formMstDistination);

                MsgForm         msgForm = (MsgForm)result[0];
                MST_DESTINATION data    = (MST_DESTINATION)result[1];

                if (msgForm.statusFlag.Equals(1))
                {
                    if (Util.isNotEmpty(data))
                    {
                        txtDistinationId.Text      = data.DESTINATION_ID;
                        txtDistinationName.Text    = data.DESTINATION_NAME;
                        txtDistinationAddress.Text = data.DESTINATION_ADDRESS;
                        //cboDistricts.SelectedValue = data.DESTINATION_DISTRICT;
                        //cboAmphure.SelectedValue = data.DESTINATION_AMPHURE;
                        //cboProvince.SelectedValue = data.DESTINATION_PROVINCE;
                        txtDistinationPostcode.Text = data.DESTINATION_POSTCODE;
                        txtDistinationTelNo.Text    = data.DESTINATION_TEL_NO;
                        txtDistinationFax.Text      = data.DESTINATION_FAX;
                        formMstDistination          = data;

                        formMstDistination.DESTINATION_DISTRICT = data.DESTINATION_DISTRICT;
                        formMstDistination.DESTINATION_AMPHURE  = data.DESTINATION_AMPHURE;
                        formMstDistination.DESTINATION_PROVINCE = data.DESTINATION_PROVINCE;

                        queryComboMstAmphures();
                        queryComboMstDistricts();

                        cboDistricts.SelectedValue = data.DESTINATION_DISTRICT;
                        cboAmphure.SelectedValue   = data.DESTINATION_AMPHURE;
                        cboProvince.SelectedValue  = data.DESTINATION_PROVINCE;
                    }
                }
                else
                {
                    MessageBox.Show("Error : " + msgForm.messageDescription);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString(), ex);
                MessageBox.Show("Error : " + ex.ToString());
            }
        }
Esempio n. 6
0
        public void deleteDataMstDestination()
        {
            MST004Controller mst004Ctrl = new MST004Controller();
            MST_DESTINATION  form       = new MST_DESTINATION();

            try
            {
                form.DESTINATION_ID = txtDistinationId.Text;

                if (Util.isEmpty(form.DESTINATION_ID))
                {
                    MessageBox.Show(CommonUtil.SELECT_DATA_DELETE);
                    return;
                }

                if (MessageBox.Show(CommonUtil.CONFIRM_DELETE_DATA, CommonUtil.TITLE_DELETE, MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    object[] result = mst004Ctrl.deleteDataMstDestination(form);

                    MsgForm msgForm = (MsgForm)result[0];

                    if (msgForm.statusFlag.Equals(1))
                    {
                        resetDataMstDistination();
                        searchDataVwMstDestination();
                        MessageBox.Show(CommonUtil.DELETE_DATA_SUCCESS);
                    }
                    else
                    {
                        MessageBox.Show("Error : " + msgForm.messageDescription);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString(), ex);
                MessageBox.Show("Error : " + ex.ToString());
            }
        }
Esempio n. 7
0
        public object[] insertOrUpdateDataMstDestination(MST_DESTINATION param, string flagAddEdit)
        {
            log.Info("Start log INFO... insertOrUpdateDataMstDestination");
            MsgForm         msgError   = new MsgForm();
            MST_DESTINATION formInsert = new MST_DESTINATION();
            MST_DESTINATION formUpdate = new MST_DESTINATION();

            try
            {
                using (var db = new PaknampoScaleDBEntities())
                {
                    formUpdate = (from row in db.MST_DESTINATION where row.DESTINATION_ID == param.DESTINATION_ID select row).FirstOrDefault();
                    if (flagAddEdit.Equals("A"))
                    {
                        if (Util.isEmpty(formUpdate))
                        {
                            //formInsert.PRODUCT_ID = db.MST_PRODUCT.Count() + 1;
                            formInsert.DESTINATION_ID       = param.DESTINATION_ID;
                            formInsert.DESTINATION_NAME     = param.DESTINATION_NAME;
                            formInsert.DESTINATION_ADDRESS  = param.DESTINATION_ADDRESS;
                            formInsert.DESTINATION_DISTRICT = param.DESTINATION_DISTRICT;
                            formInsert.DESTINATION_AMPHURE  = param.DESTINATION_AMPHURE;
                            formInsert.DESTINATION_PROVINCE = param.DESTINATION_PROVINCE;
                            formInsert.DESTINATION_POSTCODE = param.DESTINATION_POSTCODE;
                            formInsert.DESTINATION_TEL_NO   = param.DESTINATION_TEL_NO;
                            formInsert.DESTINATION_FAX      = param.DESTINATION_FAX;
                            db.MST_DESTINATION.Add(formInsert);
                            log.Info("Insert Data form MST_DESTINATION"
                                     + " DESTINATION_ID : " + formInsert.DESTINATION_ID
                                     + " DESTINATION_NAME : " + formInsert.DESTINATION_NAME
                                     + " DESTINATION_ADDRESS : " + formInsert.DESTINATION_ADDRESS
                                     + " DESTINATION_DISTRICT : " + formInsert.DESTINATION_DISTRICT
                                     + " DESTINATION_AMPHURE : " + formInsert.DESTINATION_AMPHURE
                                     + " DESTINATION_PROVINCE : " + formInsert.DESTINATION_PROVINCE
                                     + " DESTINATION_POSTCODE : " + formInsert.DESTINATION_POSTCODE
                                     + " DESTINATION_TEL_NO : " + formInsert.DESTINATION_TEL_NO
                                     + " DESTINATION_FAX : " + formInsert.DESTINATION_FAX
                                     );
                        }
                    }
                    else if (flagAddEdit.Equals("E"))
                    {
                        if (Util.isNotEmpty(formUpdate))
                        {
                            formUpdate.DESTINATION_ID       = param.DESTINATION_ID;
                            formUpdate.DESTINATION_NAME     = param.DESTINATION_NAME;
                            formUpdate.DESTINATION_ADDRESS  = param.DESTINATION_ADDRESS;
                            formUpdate.DESTINATION_DISTRICT = param.DESTINATION_DISTRICT;
                            formUpdate.DESTINATION_AMPHURE  = param.DESTINATION_AMPHURE;
                            formUpdate.DESTINATION_PROVINCE = param.DESTINATION_PROVINCE;
                            formUpdate.DESTINATION_POSTCODE = param.DESTINATION_POSTCODE;
                            formUpdate.DESTINATION_TEL_NO   = param.DESTINATION_TEL_NO;
                            formUpdate.DESTINATION_FAX      = param.DESTINATION_FAX;
                            log.Info("Update Data form MST_DESTINATION"
                                     + " DESTINATION_ID : " + formUpdate.DESTINATION_ID
                                     + " DESTINATION_NAME : " + formUpdate.DESTINATION_NAME
                                     + " DESTINATION_ADDRESS : " + formUpdate.DESTINATION_ADDRESS
                                     + " DESTINATION_DISTRICT : " + formUpdate.DESTINATION_DISTRICT
                                     + " DESTINATION_AMPHURE : " + formUpdate.DESTINATION_AMPHURE
                                     + " DESTINATION_PROVINCE : " + formUpdate.DESTINATION_PROVINCE
                                     + " DESTINATION_POSTCODE : " + formUpdate.DESTINATION_POSTCODE
                                     + " DESTINATION_TEL_NO : " + formUpdate.DESTINATION_TEL_NO
                                     + " DESTINATION_FAX : " + formUpdate.DESTINATION_FAX
                                     );
                        }
                    }
                    db.SaveChanges();
                    msgError.statusFlag = MsgForm.STATUS_SUCCESS;
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString(), ex);
                msgError.statusFlag         = MsgForm.STATUS_ERROR;
                msgError.messageDescription = ex.ToString();
            }
            finally
            {
                log.Info("End log INFO... insertOrUpdateDataMstDestination");
            }
            return(new object[] { msgError, formUpdate });
        }
Esempio n. 8
0
        public void insertOrUpdateDataMstDestination()
        {
            MST004Controller mst004Ctrl = new MST004Controller();
            MST_DESTINATION  form       = new MST_DESTINATION();

            try
            {
                if (Util.isEmpty(txtDistinationId.Text) ||
                    Util.isEmpty(txtDistinationName.Text))
                {
                    MessageBox.Show(CommonUtil.REQUIRE_MESSAGE);
                    return;
                }

                form.DESTINATION_ID       = txtDistinationId.Text;
                form.DESTINATION_NAME     = txtDistinationName.Text;
                form.DESTINATION_ADDRESS  = txtDistinationAddress.Text;
                form.DESTINATION_DISTRICT = Int32.Parse(cboDistricts.SelectedValue.ToString());
                form.DESTINATION_AMPHURE  = Int32.Parse(cboAmphure.SelectedValue.ToString());
                form.DESTINATION_PROVINCE = Int32.Parse(cboProvince.SelectedValue.ToString());
                form.DESTINATION_POSTCODE = txtDistinationPostcode.Text;
                form.DESTINATION_TEL_NO   = txtDistinationTelNo.Text;
                form.DESTINATION_FAX      = txtDistinationFax.Text;

                if (Util.isEmpty(form))
                {
                    return;
                }

                object[] result = mst004Ctrl.insertOrUpdateDataMstDestination(form, flagAddEdit);

                MsgForm         msgForm = (MsgForm)result[0];
                MST_DESTINATION data    = (MST_DESTINATION)result[1];

                if (flagAddEdit.Equals("A"))
                {
                    if (Util.isNotEmpty(data))
                    {
                        if (msgForm.statusFlag.Equals(1))
                        {
                            MessageBox.Show(CommonUtil.DUPLICATE_DATA);
                        }
                        else
                        {
                            MessageBox.Show("Error : " + msgForm.messageDescription);
                        }
                    }
                    else
                    {
                        if (msgForm.statusFlag.Equals(1))
                        {
                            resetDataMstDistination();
                            searchDataVwMstDestination();
                            MessageBox.Show(CommonUtil.SAVE_DATA_SUCCESS);
                        }
                        else
                        {
                            MessageBox.Show("Error : " + msgForm.messageDescription);
                        }
                    }
                }
                else if (flagAddEdit.Equals("E"))
                {
                    if (msgForm.statusFlag.Equals(1))
                    {
                        resetDataMstDistination();
                        searchDataVwMstDestination();
                        MessageBox.Show(CommonUtil.SAVE_DATA_SUCCESS);
                    }
                    else
                    {
                        MessageBox.Show("Error : " + msgForm.messageDescription);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString(), ex);
                MessageBox.Show("Error : " + ex.ToString());
            }
        }