Exemplo n.º 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                DateTime d1 = dtmLogin.DateTime;
                if (d1 < Convert.ToDateTime("2014-1-1"))
                {
                    DialogResult d = MessageBox.Show("新年度帐已经创立,请登录新年度操作", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
                    if (d == DialogResult.Yes)
                    {
                        return;
                    }
                }

                if (bU8Improt && lookUpAcc.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("请选择帐套", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    lookUpAcc.Focus();
                    return;
                }

                if (!chkBaseInfo())
                {
                    MessageBox.Show("请检查信息是否完整", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                string sErrInfo;

                if (!Login(out sErrInfo))
                {
                    MessageBox.Show("登陆失败!\n\n原因:\n  " + sErrInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtUID.Focus();
                    return;
                }

                if (chkPWD.Checked)
                {
                    string       sPWD      = "";
                    FrmChangePWD frmChgPWD = new FrmChangePWD();
                    frmChgPWD.ShowDialog();
                    if (frmChgPWD.DialogResult == DialogResult.OK)
                    {
                        sPWD = frmChgPWD.sNewPWD;

                        string sSQL = "update _UserInfo set vchrPwd = '" + clsDES.Encrypt(sPWD) + "' where vchrUid = '" + txtUID.Text.Trim() + "'";
                        clsSQLCommond.ExecSql(sSQL);

                        MessageBox.Show("修改密码成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }

                WriteConfig();

                try
                {
                    FrameBaseFunction.ClsBaseDataInfo.sUid          = txtUID.Text.Trim();
                    FrameBaseFunction.ClsBaseDataInfo.sLogDate      = dtmLogin.Text.Trim();
                    FrameBaseFunction.ClsBaseDataInfo.sDataBaseName = txtDataBase.Text;

                    if (bU8Improt)
                    {
                        FrameBaseFunction.ClsBaseDataInfo.sUFDataBaseName = "UFDATA_" + lookUpAcc.EditValue.ToString().Trim() + "_2015";
                        FrameBaseFunction.ClsBaseDataInfo.sUFDataBaseText = lookUpAcc.Text.Trim();
                        FrameBaseFunction.ClsBaseDataInfo.sConnString2    = FrameBaseFunction.ClsBaseDataInfo.sConnString.Replace(FrameBaseFunction.ClsBaseDataInfo.sDataBaseName, FrameBaseFunction.ClsBaseDataInfo.sUFDataBaseName);
                    }
                    string    sSQL   = "select * from dbo._UserInfo where vchrUid = '" + txtUID.Text.Trim() + "' ";
                    DataTable dtUser = clsSQLCommond.ExecQuery(sSQL);
                    FrameBaseFunction.ClsBaseDataInfo.sUserName = dtUser.Rows[0]["vchrName"].ToString().Trim();
                    FrameBaseFunction.ClsBaseDataInfo.sDepCode  = dtUser.Rows[0]["cDepCode"].ToString().Trim();

                    if (bU8Improt)
                    {
                        sSQL = "select count(*) from Master.dbo.sysdatabases where name='" + FrameBaseFunction.ClsBaseDataInfo.sUFDataBaseName + "'";
                        int iCou = Convert.ToInt32(clsSQLCommond.ExecGetScalar(sSQL));
                        if (iCou == 0)
                        {
                            MessageBox.Show("年度帐不存在,日期请选择" + dtmLogin.DateTime.AddYears(-1).ToString("yyyy").Trim() + "-12-31");
                            return;
                        }
                    }
                }
                catch
                { }

                string s提示 = "";

                #region 公告

                string s_SQL = @"
select count(1) as iCou 
from UFDLImport..杜乐公告 a inner join UFDLImport..杜乐公告明细 b on a.guid = b.guid 
where 1=1 
	and b.供应商编码 in (111111) and isnull(a.发布人,'') <> ''
	and isnull(b.阅读人,'') = ''
    ";
                s_SQL = s_SQL.Replace("111111", "select distinct vendcode from UFDLImport.._vendUid  where uid = '222222' and accid = '200'");
                s_SQL = s_SQL.Replace("222222", FrameBaseFunction.ClsBaseDataInfo.sUid);
                int iCount = 0;
                try
                {
                    iCount = Convert.ToInt32(clsSQLCommond.ExecGetScalar(s_SQL));
                }
                catch
                {
                    iCount = 9999;
                }

                if (iCount == 9999)
                {
                    MessageBox.Show("加载公告失败");
                }

                else if (iCount > 0)
                {
                    s提示 = s提示 + "存在 " + iCount.ToString().Trim() + " 条公告未看\n";
                }

                #endregion

                #region 8D报告

                try
                {
                    s_SQL = @"
select cast(0 as bit) as 选择
    ,* 
from DolleDatabase.dbo._Bai_到货不良品处理流程 a
	left join UFDLImport.._8D报告 b on a.id = b.idhead
where 是否提交8D改进报告 = '是' and 1=1 and  a.厂商编码 in (111111)
    and isnull(b.状态,0) <> 1
Order by id
";
                    s_SQL = s_SQL.Replace("111111", "select distinct vendcode from UFDLImport.._vendUid  where uid = '222222' and accid = '200'");
                    s_SQL = s_SQL.Replace("222222", FrameBaseFunction.ClsBaseDataInfo.sUid);
                    DataTable dt8D = clsSQLCommond.ExecQuery(s_SQL);
                    if (dt8D != null && dt8D.Rows.Count > 0)
                    {
                        s提示 = s提示 + "存在 " + dt8D.Rows.Count.ToString().Trim() + " 条8D改进报告未处理完成\n";
                    }
                }
                catch { }

                #endregion


                if (s提示.Trim() != "")
                {
                    MessageBox.Show(s提示);
                }
                DialogResult = DialogResult.OK;
            }
            catch (Exception ee)
            {
                MessageBox.Show("登陆失败! " + ee.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (bU8Improt && lookUpAcc.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("请选择帐套", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    lookUpAcc.Focus();
                    return;
                }

                if (!chkBaseInfo())
                {
                    MessageBox.Show("请检查信息是否完整", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                string sErrInfo;

                if (!Login(out sErrInfo))
                {
                    MessageBox.Show("登陆失败!\n\n原因:\n  " + sErrInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtUID.Focus();
                    return;
                }

                if (chkPWD.Checked)
                {
                    string       sPWD      = "";
                    FrmChangePWD frmChgPWD = new FrmChangePWD();
                    frmChgPWD.ShowDialog();
                    if (frmChgPWD.DialogResult == DialogResult.OK)
                    {
                        sPWD = frmChgPWD.sNewPWD;

                        string sSQL = "update _UserInfo set vchrPwd = '" + clsDES.Encrypt(sPWD) + "' where vchrUid = '" + txtUID.Text.Trim() + "'";
                        clsSQLCommond.ExecSql(sSQL);

                        MessageBox.Show("修改密码成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }

                WriteConfig();

                try
                {
                    FrameBaseFunction.ClsBaseDataInfo.sUid          = txtUID.Text.Trim();
                    FrameBaseFunction.ClsBaseDataInfo.sLogDate      = dtmLogin.Text.Trim();
                    FrameBaseFunction.ClsBaseDataInfo.sDataBaseName = txtDataBase.Text;

                    if (bU8Improt)
                    {
                        FrameBaseFunction.ClsBaseDataInfo.sUFDataBaseName = "UFDATA_" + lookUpAcc.EditValue.ToString().Trim() + "_" + dtmLogin.DateTime.ToString("yyyy").Trim();
                        FrameBaseFunction.ClsBaseDataInfo.sUFDataBaseText = lookUpAcc.Text.Trim();
                        FrameBaseFunction.ClsBaseDataInfo.sConnString2    = FrameBaseFunction.ClsBaseDataInfo.sConnString.Replace(FrameBaseFunction.ClsBaseDataInfo.sDataBaseName, FrameBaseFunction.ClsBaseDataInfo.sUFDataBaseName);
                    }
                    string sSQL = "select vchrName from dbo._UserInfo where vchrUid = '" + txtUID.Text.Trim() + "' ";
                    FrameBaseFunction.ClsBaseDataInfo.sUserName = clsSQLCommond.ExecGetScalar(sSQL).ToString().Trim();

                    if (bU8Improt)
                    {
                        sSQL = "select count(*) from Master.dbo.sysdatabases where name='" + FrameBaseFunction.ClsBaseDataInfo.sUFDataBaseName + "'";
                        int iCou = Convert.ToInt32(clsSQLCommond.ExecGetScalar(sSQL));
                        if (iCou == 0)
                        {
                            MessageBox.Show("年度帐不存在,日期请选择" + dtmLogin.DateTime.AddYears(-1).ToString("yyyy").Trim() + "-12-31");
                            return;
                        }
                    }
                }
                catch
                { }

                DialogResult = DialogResult.OK;
            }
            catch (Exception ee)
            {
                MessageBox.Show("登陆失败! " + ee.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }