Ejemplo n.º 1
0
        void txtMa_Dt_Validating(object sender, CancelEventArgs e)
        {
            string strValue = txtMa_Dt.Text.Trim();
            bool   bRequire = false;

            frmDoiTuong frmLookup = new frmDoiTuong();
            DataRow     drLookup  = Lookup.ShowLookup(frmLookup, "LIDOITUONG", "Ma_Dt", strValue, bRequire, "");

            if (bRequire && drLookup == null)
            {
                e.Cancel = true;
            }

            if (drLookup == null)
            {
                txtMa_Dt.Text  = string.Empty;
                lbtTen_Dt.Text = string.Empty;
            }
            else
            {
                txtMa_Dt.Text  = drLookup["Ma_Dt"].ToString();
                lbtTen_Dt.Text = drLookup["Ten_Dt"].ToString();
            }

            dicName[lbtTen_Dt.Name] = lbtTen_Dt.Text;

            if ((((txtTextLookup)sender).AutoFilter != null) && ((txtTextLookup)sender).AutoFilter.Visible)
            {
                ((txtTextLookup)sender).AutoFilter.Visible = false;
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
            }
        }
Ejemplo n.º 2
0
        void txtMa_Dt_Validating(object sender, CancelEventArgs e)
        {
            Common.ResetTextChange(this);

            string strValue = txtMa_Dt.Text.Trim();
            bool   bRequire = true;

            frmDoiTuong frmLookup = new frmDoiTuong();
            DataRow     drLookup  = Lookup.ShowLookup(frmLookup, "LIDOITUONG", "Ma_Dt", strValue, bRequire, "");

            if (bRequire && drLookup == null)
            {
                e.Cancel = true;
            }

            if (drLookup == null)
            {
                txtMa_Dt.Text  = string.Empty;
                txtTen_Dt.Text = string.Empty;
            }
            else
            {
                txtMa_Dt.Text = drLookup["Ma_Dt"].ToString();

                if (txtMa_Dt.bTextChange)
                {
                    txtTen_Dt.Text  = drLookup["Ten_Dt"].ToString();
                    txtDia_Chi.Text = drLookup["Dia_Chi"].ToString();
                }

                //Cap nhat xuong chi tiet
                if (txtMa_Dt.Text != (string)drEditPh["Ma_Dt"])
                {
                    foreach (DataRow dr in dtEditCt.Rows)
                    {
                        if ((string)dr["Ma_Dt"] == (string)drEditPh["Ma_Dt"])
                        {
                            dr["Ma_Dt"] = txtMa_Dt.Text;
                        }
                    }
                }
            }

            //dicName[txtTen_Dt.Name] = txtTen_Dt.Text;

            Common.GatherMemvar(this, ref drEditPh);

            if ((((txtTextLookup)sender).AutoFilter != null) && ((txtTextLookup)sender).AutoFilter.Visible)
            {
                ((txtTextLookup)sender).AutoFilter.Visible = false;
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
            }
        }
Ejemplo n.º 3
0
        void txtMa_So_Thue_Validating(object sender, CancelEventArgs e)
        {
            string strValue = txtMa_So_Thue.Text.Trim();

            bool bRequire = false;

            drCurrent = ((DataRowView)bdsEditCt.Current).Row;

            if (strValue == "/" || strValue == @"\")
            {
                frmDoiTuong frmLookup = new frmDoiTuong();
                DataRow     drLookup  = Lookup.ShowLookup(frmLookup, "LIDOITUONG", "Ma_So_Thue", strValue, bRequire, "");

                if (bRequire && drLookup == null)
                {
                    e.Cancel = true;
                }

                if (drLookup == null)
                {
                    txtMa_So_Thue.Text = string.Empty;
                }
                else
                {
                    txtMa_So_Thue.Text = drLookup["Ma_So_Thue"].ToString();
                    txtTen_DtGtgt.Text = drLookup["Ten_Dt"].ToString();
                }
            }
            else if (strValue != string.Empty && txtMa_So_Thue.bTextChange)
            {
                DataTable dtLookup = SQLExec.ExecuteReturnDt("SELECT * FROM LIDOITUONG WHERE Ma_So_Thue = '" + strValue + "'");

                if (dtLookup != null)
                {
                    if (dtLookup.Rows.Count == 1)
                    {
                        txtMa_So_Thue.Text = dtLookup.Rows[0]["Ma_So_Thue"].ToString();
                        txtTen_DtGtgt.Text = dtLookup.Rows[0]["Ten_Dt"].ToString();
                    }
                    else
                    {
                        dtLookup = SQLExec.ExecuteReturnDt("SELECT * FROM LIDOITUONG WHERE Ma_So_Thue LIKE '" + strValue + "%'");

                        if (dtLookup.Rows.Count >= 1)
                        {
                            frmDoiTuong frmLookup = new frmDoiTuong();
                            DataRow     drLookup  = Lookup.ShowLookup(frmLookup, "LIDOITUONG", "Ma_So_Thue", strValue, bRequire, "");

                            if (bRequire && drLookup == null)
                            {
                                e.Cancel = true;
                            }

                            if (drLookup == null)
                            {
                                txtMa_So_Thue.Text = string.Empty;
                                txtTen_DtGtgt.Text = string.Empty;
                            }
                            else
                            {
                                txtMa_So_Thue.Text = drLookup["Ma_So_Thue"].ToString();
                                txtTen_DtGtgt.Text = drLookup["Ten_Dt"].ToString();
                            }
                        }
                        else
                        {
                            if (Common.MsgYes_No("Bạn có chắc chắn thêm mới Đối tượng - Mã số thuế?"))
                            {
                                DataRow drNew = dtLookup.NewRow();
                                drNew["Ma_Dt"]    = drNew["Ma_So_Thue"] = strValue;
                                drNew["Ma_Nh_Dt"] = "MA_SO_THUE";

                                frmDoiTuong_Edit frmEdit = new frmDoiTuong_Edit();
                                frmEdit.Load(enuEdit.New, drNew);

                                if (frmEdit.isAccept)
                                {
                                    txtMa_So_Thue.Text = (string)drNew["Ma_So_Thue"];
                                    txtTen_DtGtgt.Text = (string)drNew["Ten_Dt"];
                                }
                            }
                        }
                    }
                }
            }
            //this.SelectNextControl(this.ActiveControl, true, true, true, true);
        }