Beispiel #1
0
        private void txtCustcode_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                string connection_string = Utils.getConnectionstr();
                LinqtoSQLDataContext dc  = new LinqtoSQLDataContext(connection_string);
                string valueseach        = txtposmproduct.Text;

                var rs = from pp in dc.tbl_MKT_Stockends
                         where pp.MATERIAL.Contains(valueseach) || pp.Description.Contains(valueseach) || pp.SAP_CODE.Contains(valueseach) || pp.ITEM_Code.Contains(valueseach)
                         group pp by pp.ITEM_Code into g
                         select new
                {
                    ITEM_Code   = g.Key,
                    SAP_CODE    = g.Select(x => x.SAP_CODE).FirstOrDefault(),
                    MATERIAL    = g.Select(x => x.MATERIAL).FirstOrDefault(),
                    Description = g.Select(x => x.Description).FirstOrDefault(),
                    UNIT        = g.Select(x => x.UNIT).FirstOrDefault(),

                    id = g.Select(x => x.id).FirstOrDefault(),
                };



                if (rs != null)
                {
                    View.MKTViewchooseiquery selectkq = new MKTViewchooseiquery(rs, dc, "PLEASE SELECT PRODUCTS ", "id");
                    selectkq.ShowDialog();
                    int id = selectkq.id;

                    //dt.Columns.Add(new DataColumn("MATERIAL", typeof(string)));
                    //dt.Columns.Add(new DataColumn("Description", typeof(string)));
                    //dt.Columns.Add(new DataColumn("ITEM_Code", typeof(string)));
                    //dt.Columns.Add(new DataColumn("Sap_Code", typeof(string)));

                    //dt.Columns.Add(new DataColumn("Unit", typeof(string)));
                    //dt.Columns.Add(new DataColumn("Issue_Quantity", typeof(float)));
                    //dt.Columns.Add(new DataColumn("Available_Quantity", typeof(float)));


                    var valuechon = (from pp in dc.tbl_MKT_Stockends
                                     where pp.id == id
                                     select pp).FirstOrDefault();

                    if (valuechon != null)
                    {
                        txtsapcode.Text     = valuechon.ITEM_Code;
                        txtid.Text          = valuechon.id.ToString();
                        txtname.Text        = valuechon.MATERIAL;
                        txtdescription.Text = valuechon.Description;
                        txtprice.Focus();
                        this.id = id;
                    }
                }
            }
        }
        private void txtionumber_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                //  cbsophieu.
                e.Handled = true;

                string seachtext         = txtionumber.Text;
                string connection_string = Utils.getConnectionstr();
                LinqtoSQLDataContext dc  = new LinqtoSQLDataContext(connection_string);

                //var rs = from pp in dc.tbl_MKT_IO_Programes
                //         where pp.tenCT.Contains(seachtext)
                //         select new
                //         {
                //             MÃ_CHƯƠNG_TRÌNH = pp.macT,
                //             TÊN_CHƯƠNG_TRÌNH = pp.tenCT,



                //             pp.id,

                //         };

                var rs = Model.MKT.DanhsachctMKTSeachbyIOseach(dc, txtionumber.Text);

                View.MKTViewchooseiquery selectkq = new MKTViewchooseiquery(rs, dc, "PLEASE SELECT PURPOSE ", "MKT");
                selectkq.ShowDialog();
                int id = selectkq.id;

                var rs2 = (from pp in dc.tbl_MKT_IO_Programes
                           where pp.id == id
                           select pp).FirstOrDefault();

                if (rs2 != null)
                {
                    txtionumber.Text     = rs2.IO_number;
                    txttenct.Text        = rs2.IO_Name;
                    txtsohieuct.Text     = rs2.ProgrameIDDocno;
                    this.ionumber        = rs2.IO_number;
                    this.ProgrameIDDocno = rs2.IO_number;
                }



                txtchargetoaccount.Focus();


                //    dataGridViewDetail.Focus();
            }
        }
        private void txtCustcode_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                // chanel of IO
                string seachtext         = txtCustomercode.Text;
                string connection_string = Utils.getConnectionstr();
                LinqtoSQLDataContext dc  = new LinqtoSQLDataContext(connection_string);

                string channelgroup = (from pp in dc.tbl_MKT_IO_Programes
                                       where pp.IO_number == this.Ionumber
                                       select pp.ChannelGroup).FirstOrDefault();


                string[] chanelparts = channelgroup.Split(';');

                //st1 = parts[0].Trim();
                //st2 = parts[1].Trim();
                //st3 = parts[2].Trim();
                //st4 = parts[3].Trim();

                var rs = from pp in dc.tbl_MKT_Soldtocodes
                         where pp.FullNameN.Contains(seachtext) &&
                         pp.Soldtype == true &&
                         chanelparts.Contains(pp.Chanel)

                         select new
                {
                    MÃ_KHÁCH_HÀNG  = pp.Customer,
                    TÊN_KHÁCH_HÀNG = pp.FullNameN,
                    ĐỊA_CHỈ        = pp.Street + " " + pp.District + " " + pp.City,
                    pp.KeyAcc,
                    pp.Chanel,
                    pp.Region,
                    pp.SalesOrg,
                    pp.District,
                    //QUẬN = pp.District,
                    //TỈNH_THÀNH_PHỐ = pp.City,
                    //ĐIỆN_THOẠI = pp.Telephone1,
                    //GHI_CHÚ = pp.Note,



                    ID = pp.id,
                };

                View.MKTViewchooseiquery selectkq = new MKTViewchooseiquery(rs, dc, "PLEASE SELECT RECIPIENTS", "MKT");
                selectkq.ShowDialog();
                int id = selectkq.id;

                var rs2 = (from pp in dc.tbl_MKT_Soldtocodes
                           where pp.id == id
                           select pp).FirstOrDefault();

                if (rs2 != null)
                {
                    txtCustomercode.Text    = rs2.Customer;
                    txtcustomername.Text    = rs2.FullNameN;
                    txtcustomeraddress.Text = rs2.Street + " ," + rs2.District + " ," + rs2.City;
                    txtbudget.Text          = "0";

                    this.customercode   = rs2.Customer;
                    this.customername   = rs2.FullNameN;
                    this.customeradress = rs2.Street + " ," + rs2.District + " ," + rs2.City;
                    this.budget         = 0;
                }


                txtbudget.Focus();
            }
        }