public PrintLetterOption()
        {
            InitializeComponent();
            lbnamecode.Text = "";
            this.choice     = 0;
            //   this.cb_printall.CheckState = CheckState.Checked;
            this.cb_groupprit.CheckState      = CheckState.Unchecked;
            this.cb_onlycode.CheckState       = CheckState.Unchecked;
            this.cb_fromcodetocode.CheckState = CheckState.Unchecked;


            #region  customer senđing grup data



            //try
            //{
            List <Viewtable.ComboboxItem> dataCollection = new List <Viewtable.ComboboxItem>();


            string connection_string = Utils.getConnectionstr();
            LinqtoSQLDataContext db  = new LinqtoSQLDataContext(connection_string);
            db.CommandTimeout = 0;

            var ListCustomre = db.ExecuteQuery <string>("SELECT DISTINCT SendingGroup FROM tblCustomer WHERE tblCustomer.Reportsend = 'true'").ToList();



            foreach (var item in ListCustomre)
            {
                if (item != null)
                {
                    Viewtable.ComboboxItem itemcb = new Viewtable.ComboboxItem();

                    itemcb.Value = item;
                    itemcb.Text  = item;

                    dataCollection.Add(itemcb);
                }
            }


            input_groupcode.DataSource = dataCollection;



            //   }
            //catch (Exception ex)
            //{

            //    MessageBox.Show(ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);

            //}

            #endregion
        }
        public VInputchange(string lbheader, string lbsub, LinqtoSQLDataContext db, string tblnamemain, string tblnamesub, System.Type Typeofftablemain, System.Type Typeofftablsub, String IDmain, String IDsub, string Username)//;//, string username, int codeinput
        {
            InitializeComponent();
            this.KeyPreview = true;
            this.KeyUp     += new System.Windows.Forms.KeyEventHandler(Control_KeyPress);

            this.Username = Username;

            this.btrigh.Visible = false;

            if (tblnamesub == "tbl_Temp")
            {
                this.btrigh.Visible = true;
            }

            this.lbseachedit.Visible    = false;
            this.Bt_uploadbegin.Visible = false;
            // this.lbusername.Text = Utils.getusername();



            this.bnt_adddataselected.Visible = false;
            this.Bt_Adddata.Visible          = true;
            if (lbheader == "")
            {
                //    this.p
                this.mainpanel.Hide();
                this.Bt_Adddata.Hide();
                this.splitContainer1.Panel2Collapsed = true;
            }


            if (lbsub == "LIST MASTER DATA CUSTOMER ")
            {
                this.lbseachedit.Visible = true;
            }


            if (tblnamemain == "tbl_CustomerneedLetter")
            {
                this.Bt_Adddata.Visible = false;
            }

            // lbseachedit
            if (tblnamemain == "tbl_kacontractbegindata" || tblnamemain == "tbl_kacontractsdatadetail")
            {
                this.lbseachedit.Visible = true;
            }



            this.db               = db;
            this.tblnamemain      = tblnamemain;
            this.tblnamesub       = tblnamesub;
            this.Typeofftablemain = Typeofftablemain;
            this.Typeofftablesub  = Typeofftablsub;
            //  this.tblnamesub = tblnamesub;

            this.IDmain = IDmain;
            this.IDsub  = IDsub;

            this.lb_headermain.Text = lbheader;
            this.lb_headersub.Text  = lbsub;


            string slqtext = "select * from " + tblnamemain;

            var results3 = db.ExecuteQuery(Typeofftablemain, slqtext);

            source2 = new BindingSource();
            //   TableAdapter = source2.tablead

            source2.DataSource = results3;

            this.dataGridView2.DataSource = source2;  // view 2 la main view 1 detaik

            this.dataGridView2.AllowUserToAddRows = true;



            if (this.dataGridView2.Columns[IDmain] != null)
            {
                //      this.dataGridView2.Columns[IDmain].Visible = false;
            }



            if (Username != "")
            {
                slqtext = "select *  from  " + tblnamesub + " where " + tblnamesub + ".Username ='******'"; // EXCEPT (" + IDsub + ")
            }
            else
            {
                slqtext = "select *  from  " + tblnamesub; // EXCEPT (" + IDsub + ")
            }



            var results2 = db.ExecuteQuery(Typeofftablesub, slqtext);

            source1            = new BindingSource();
            source1.DataSource = results2;
            source1.AllowNew   = true;

            this.dataGridView1.DataSource = source1;
            //if (tblnamesub == "USERNAME AND PASSWORD CONFIG ! ")

            //{


            //    dataGridView1.Columns["username"].DisplayIndex = 2;


            //};


            //if (this.dataGridView1.Columns["Username"] != null)
            //{
            //    this.dataGridView1.Columns.Remove("Username");
            //    //  MessageBox.Show("ok");
            //}

            //    nếu daraa bàng không thì tao mọt bản gi mới và xem lại

            if (source1.Count == 0)
            {
                #region if tbl_kacontracttype null


                if (tblnamesub == "tbl_kacontracttype")
                {
                    //       MessageBox.Show("ok !!!!!!!!");
                    string connection_string = Utils.getConnectionstr();
                    //      UpdateDatagridview
                    System.Data.DataTable dt = new System.Data.DataTable();
                    LinqtoSQLDataContext  dc = new LinqtoSQLDataContext(connection_string);
                    var rsthisperiod         = from tbl_kacontracttype in dc.tbl_kacontracttypes
                                               select tbl_kacontracttype;

                    Utils ut = new Utils();
                    dt = ut.ToDataTable(dc, rsthisperiod);

                    this.dataGridView1.DataSource = dt;
                }
                #endregion if tbl_kacontracttype null


                #region if tbl_kacurrency null


                if (tblnamesub == "tbl_kacurrency")
                {
                    //       MessageBox.Show("ok !!!!!!!!");
                    string connection_string = Utils.getConnectionstr();
                    //      UpdateDatagridview
                    System.Data.DataTable dt = new System.Data.DataTable();
                    LinqtoSQLDataContext  dc = new LinqtoSQLDataContext(connection_string);
                    var rsthisperiod         = from tbl_kacurrency in dc.tbl_kacurrencies
                                               select tbl_kacurrency;

                    Utils ut = new Utils();
                    dt = ut.ToDataTable(dc, rsthisperiod);

                    this.dataGridView1.DataSource = dt;
                }
                #endregion if tbl_kacurrency null



                #region if tbl_Kafuctionlist null


                if (tblnamesub == "tbl_Kafuctionlist")
                {
                    //       MessageBox.Show("ok !!!!!!!!");
                    string connection_string = Utils.getConnectionstr();
                    //      UpdateDatagridview
                    System.Data.DataTable dt = new System.Data.DataTable();
                    LinqtoSQLDataContext  dc = new LinqtoSQLDataContext(connection_string);
                    var rsthisperiod         = from tbl_Kafuctionlist in dc.tbl_Kafuctionlists
                                               select tbl_Kafuctionlist;

                    Utils ut = new Utils();
                    dt = ut.ToDataTable(dc, rsthisperiod);

                    this.dataGridView1.DataSource = dt;
                }
                #endregion if tbl_Kafuctionlist null


                #region if tbl_kaPrdgrp null


                if (tblnamesub == "tbl_kaPrdgrp")
                {
                    //       MessageBox.Show("ok !!!!!!!!");
                    string connection_string = Utils.getConnectionstr();
                    //      UpdateDatagridview
                    System.Data.DataTable dt = new System.Data.DataTable();
                    LinqtoSQLDataContext  dc = new LinqtoSQLDataContext(connection_string);
                    var rsthisperiod         = from tbl_kaPrdgrp in dc.tbl_kaPrdgrps
                                               select tbl_kaPrdgrp;

                    Utils ut = new Utils();
                    dt = ut.ToDataTable(dc, rsthisperiod);

                    this.dataGridView1.DataSource = dt;
                }
                #endregion if tbl_Kafuctionlist null


                // "tbl_Temp")



                #region if tbl_Temp null


                if (tblnamesub == "tbl_Temp")
                {
                    //       MessageBox.Show("ok !!!!!!!!");
                    string connection_string = Utils.getConnectionstr();
                    //      UpdateDatagridview
                    System.Data.DataTable dt = new System.Data.DataTable();
                    LinqtoSQLDataContext  dc = new LinqtoSQLDataContext(connection_string);
                    var rsthisperiod         = from tbl_Temp in dc.tbl_Temps
                                               select tbl_Temp;

                    Utils ut = new Utils();
                    dt = ut.ToDataTable(dc, rsthisperiod);

                    this.dataGridView1.DataSource = dt;
                }
                #endregion if tbl_Kafuctionlist null

                //      tbl_PaymentTerm


                #region if tbl_PaymentTerm null


                if (tblnamesub == "tbl_PaymentTerm")
                {
                    //       MessageBox.Show("ok !!!!!!!!");
                    string connection_string = Utils.getConnectionstr();
                    //      UpdateDatagridview
                    System.Data.DataTable dt = new System.Data.DataTable();
                    LinqtoSQLDataContext  dc = new LinqtoSQLDataContext(connection_string);
                    var rsthisperiod         = from tbl_PaymentTerm in dc.tbl_PaymentTerms
                                               select tbl_PaymentTerm;

                    Utils ut = new Utils();
                    dt = ut.ToDataTable(dc, rsthisperiod);

                    this.dataGridView1.DataSource = dt;
                }
                #endregion if tbl_PaymentTerm null


                #region if tbl_kaChannel null


                if (tblnamesub == "tbl_kaChannel")
                {
                    //       MessageBox.Show("ok !!!!!!!!");
                    string connection_string = Utils.getConnectionstr();
                    //      UpdateDatagridview
                    System.Data.DataTable dt = new System.Data.DataTable();
                    LinqtoSQLDataContext  dc = new LinqtoSQLDataContext(connection_string);
                    var rsthisperiod         = from tbl_kaChannel in dc.tbl_kaChannels
                                               select tbl_kaChannel;

                    Utils ut = new Utils();
                    dt = ut.ToDataTable(dc, rsthisperiod);

                    this.dataGridView1.DataSource = dt;
                }
                #endregion if tbl_PaymentTerm null
            }

            ///        tạo một bản gi mưới



            this.dataGridView1.AutoGenerateColumns = true;
            if (this.dataGridView1.Columns[IDsub] != null)
            {
                this.dataGridView1.Columns[IDsub].Visible = false;
            }

            dataGridView1.Update();
            this.dataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText;
            this.dataGridView2.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText;
        }
Exemple #3
0
        public VInputchange(string lbheader, string lbsub, LinqtoSQLDataContext db, string tblnamemain, string tblnamesub, System.Type Typeofftable, String IDmain, String IDsub)
        {
            InitializeComponent();


            //     #region right setup
            this.lbseachedit.Visible    = false;
            this.Bt_uploadbegin.Visible = false;
            string enduser = Utils.getusername();


            this.bnt_adddataselected.Visible = false;
            this.Bt_Adddata.Visible          = true;
            if (lbheader == "")
            {
                //    this.p
                this.mainpanel.Hide();
                this.Bt_Adddata.Hide();
                this.splitContainer1.Panel2Collapsed = true;
            }


            if (lbsub == "LIST MASTER DATA CUSTOMER ")
            {
                this.lbseachedit.Visible = true;
            }



            this.db           = db;
            this.tblnamemain  = tblnamemain;
            this.tblnamesub   = tblnamesub;
            this.Typeofftable = Typeofftable;
            this.IDmain       = IDmain;
            this.IDsub        = IDsub;

            this.lb_headermain.Text = lbheader;
            this.lb_headersub.Text  = lbsub;


            string slqtext = "select * from " + tblnamemain + " where " + tblnamemain + ".enduser ='******'";



            var results3 = db.ExecuteQuery(Typeofftable, slqtext);


            source2            = new BindingSource();
            source2.AllowNew   = true;
            source2.DataSource = results3;


            this.dataGridView2.DataSource = source2;  // view 2 la main view 1 detaik

            this.dataGridView2.AllowUserToAddRows = true;



            if (this.dataGridView2.Columns[IDmain] != null)
            {
                this.dataGridView2.Columns[IDmain].Visible = false;
            }



            slqtext = "select *  from  " + tblnamesub + " where " + tblnamesub + ".enduser ='******'";

            if (lbsub == "USERNAME AND PASSWORD")
            {
                slqtext = "select *  from  " + tblnamesub;// + " where " + tblnamesub + ".enduser ='******'";
            }

            var results2 = db.ExecuteQuery(Typeofftable, slqtext);


            source1          = new BindingSource();
            source1.AllowNew = true;
            //if (results2 == null)
            //{
            //    source1.AddNew();
            //}
            source1.DataSource = results2;

            this.dataGridView1.DataSource = source1;

            this.dataGridView1.AutoGenerateColumns = true;



            if (this.dataGridView1.Columns[IDsub] != null)
            {
                this.dataGridView1.Columns[IDsub].Visible = false;
            }


            this.dataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText;
            this.dataGridView2.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText;



            //tblCustomer cct = new tblCustomer();
            //cct.Customer = 90;
        }