Esempio n. 1
0
        private void btn_login_Click(object sender, EventArgs e)
        {
            if (checkdata() == false)
            {
                return;
            }
            string sqlusername   = "******" + cmb_user.Text + "'";
            string sqlpass       = "******" + cmb_user.Text + "'";
            string sqlpermission = "select distinct permission from m_user where  usercode = '" + cmb_user.Text + "'";
            sqlCON connect       = new sqlCON();

            if (connect.sqlExecuteScalarString(sqlpass) != txt_pass.Text)
            {
                infomesge mes = new infomesge();
                mes.ErrorMesger("Password is not correct", "Warning System", this);
                txt_pass.Text = "";
                return;
            }
            sqlCON connected = new sqlCON();
            sqlCON permi     = new sqlCON();

            Class.valiballecommon va = Class.valiballecommon.GetStorage();
            va.UserName   = connected.sqlExecuteScalarString(sqlusername);
            va.Permission = permi.sqlExecuteScalarString(sqlpermission);
            va.UserCode   = cmb_user.Text;
            MainFr newfr = new MainFr();

            newfr.Show();
            //this.Hide();
        }
        void getERPdata()
        {
            DateTime dateto   = dtp_to.Value.Date;
            DateTime datefrom = dtp_from.Value.Date;

            dt = new DataTable();
            StringBuilder sql = new StringBuilder();

            sql.Append(@"select
CONVERT(date,coptcs.CREATE_DATE) as Create_Date,
coptcs.TC001 as Code_Type, 
coptcs.TC002 as Code_No,
coptcs.TC012 as Customer_No

 from COPTC coptcs
where 1=1 ");
            //if(ChooseDeptoSQLcommand(trv_department) != "")
            // {
            //     sql.Append(ChooseDeptoSQLcommand(trv_department));
            // }
            if (cmd_COPTC_TC001.Text != "")
            {
                sql.Append(" and coptcs.TC001   = '" + cmd_COPTC_TC001.Text + "'");
            }
            if (cmd_COPTC_TC002.Text != "")
            {
                sql.Append(" and coptcs.TC002   = '" + cmd_COPTC_TC002.Text + "'");
            }


            else
            {
                sql.Append(" and CONVERT(date,coptcs.CREATE_DATE)  >= '" + datefrom + "' ");
                sql.Append(" and CONVERT(date,coptcs.CREATE_DATE) <= '" + dateto + "' ");
            }
            sql.Append(@" group by 
                                   coptcs.CREATE_DATE,
                                    coptcs.TC001 ,
                                    coptcs.TC002 ,
                                   coptcs.TC012
                                    ");
            sql.Append(" order by coptcs.TC001, coptcs.TC002");
            sqlERPCON con = new sqlERPCON();

            con.sqlDataAdapterFillDatatable(sql.ToString(), ref dt);
            //checkdata
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string sqlcheck   = "";
                    string NgayTaoDon = dt.Rows[i]["Create_Date"].ToString().Replace("'", "");
                    string MaTaoDon   = dt.Rows[i]["Code_Type"].ToString().Replace("'", "");
                    string codeDon    = dt.Rows[i]["Code_No"].ToString().Replace("'", "");
                    string MAHK       = dt.Rows[i]["Customer_No"].ToString().Replace("'", "");
                    sqlcheck = "select COUNT(*) from t_OCTM where TM01 = '" + NgayTaoDon + "' and TM02 ='" + MaTaoDon + "' and TM03= '" + codeDon + "' and TM04 = '" + MAHK + "'";
                    sqlCON check = new sqlCON();
                    if (int.Parse(check.sqlExecuteScalarString(sqlcheck)) == 0) //insert
                    {
                        string list = "";
                        for (int j = 0; j < dt.Columns.Count; j++)
                        {
                            list += "'";
                            list += dt.Rows[i][j].ToString().Replace("'", "") + "',";
                        }
                        StringBuilder sqlinsert = new StringBuilder();
                        sqlinsert.Append("insert into t_OCTM ");
                        sqlinsert.Append(@"(TM01,TM02,TM03,TM04,UserName,datetimeRST) values ( ");
                        sqlinsert.Append(list);
                        sqlinsert.Append("'" + Class.valiballecommon.GetStorage().UserName + "',GETDATE())");
                        sqlCON insert = new sqlCON();
                        insert.sqlExecuteNonQuery(sqlinsert.ToString(), false);
                    }
                }
            }
        }
Esempio n. 3
0
        private void btn_login_Click(object sender, EventArgs e)
        {
            //MySql_importfg_warehouse tem = new MySql_importfg_warehouse();
            //if (tem.Open())
            //{
            //    MessageBox.Show("Connect Mysql sucess");
            //    return;
            //}
            //else
            //{
            //    return;
            //}
            if (checkdata() == false)
            {
                return;
            }
            string sqlusername   = "******" + cmb_user.Text + "'";
            string sqlpass       = "******" + cmb_user.Text + "'";
            string sqlpermission = "select distinct permission from m_user where  usercode = '" + cmb_user.Text + "'";
            sqlCON connect       = new sqlCON();

            if (connect.sqlExecuteScalarString(sqlpass) != txt_pass.Text)
            {
                infomesge mes = new infomesge();
                mes.ErrorMesger("Password is not correct", "Warning System", this);
                txt_pass.Text = "";
                return;
            }
            sqlCON connected = new sqlCON();
            sqlCON permi     = new sqlCON();

            Class.valiballecommon va = Class.valiballecommon.GetStorage();
            va.UserName   = connected.sqlExecuteScalarString(sqlusername);
            va.Permission = permi.sqlExecuteScalarString(sqlpermission);
            va.UserCode   = cmb_user.Text;
            if (cb_Language.SelectedItem != null)
            {
                va.Language = (string)cb_Language.SelectedItem;
            }
            if (cb_Database.SelectedItem != null)
            {
                if (cb_Database.SelectedItem.ToString() == "TECHLINK")
                {
                    va.DBERP = "TECHLINK";
                    va.DBSFT = "SFT_TECHLINK";
                }
                else if (cb_Database.SelectedItem.ToString() == "TLVN2")
                {
                    va.DBERP = "TLVN2";
                    va.DBSFT = "SFT_TLVN2";
                }
                else if (cb_Database.SelectedItem.ToString() == "TEST03152021")
                {
                    va.DBERP = "TEST03152021";
                    va.DBSFT = "SFT_TEST03152021";
                }
            }
            MainLayout mainLayout = new MainLayout();

            mainLayout.Show();
            //this.Hide();
            //MainFr newfr = new MainFr();
            //newfr.Show();
            //   this.Hide();
        }