示例#1
0
 private void btnLogon_Click(object sender, EventArgs e)
 {
     if (txtUserId.Text == "")
     {
         MessageBox.Show(@"请输入登录帐号!!", Resources.T提示);
         txtUserId.Focus();
     }
     else
     {
         var sql = $"SELECT TOP 1 * FROM IDPASS WHERE ID='{txtUserId.Text.Trim()}'";
         try
         {
             var dr = SqlHelper.ExecuteReader(SqlHelper.GetConnSting(), CommandType.Text, sql);
             if (dr.Read())
             {
                 var pass = dr["pass"].ToString().Trim();
                 if (txtPassword.Text.Trim() == pass)
                 {
                     SqlHelper.UserName = dr["name"].ToString().Trim();
                     SqlHelper.UserType = dr["leiq"].ToString().Trim();
                     SqlHelper.DeptId   = dr["DeptId"].ToString().Trim();
                     SqlHelper.UserId   = txtUserId.Text.Trim();
                     Hide();
                     BLogin       = true;
                     DialogResult = DialogResult.OK;
                 }
                 else
                 {
                     MessageBox.Show(@"密码错误,请重新输入!", Resources.T提示);
                     txtPassword.Text = "";
                     txtPassword.Focus();
                 }
             }
             else
             {
                 MessageBox.Show($"此帐号< {txtUserId.Text.Trim()} >不存在,请重新输入!!", Resources.T提示);
                 txtUserId.Text   = "";
                 txtPassword.Text = "";
                 txtUserId.Focus();
             }
             dr.Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show(@"数据库连接错误!" + ex.Message);
         }
     }
 }
        /// <summary>
        ///     工单单号变化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtWONo_TextChanged(object sender, EventArgs e)
        {
            if (txtWONo.Text.Length != 7)
            {
                return;
            }
            var sql =
                "SELECT shigongdanhao 工单号,dingdanhao 生产单号,kehu 客户,jiaohuoqi 交货期,tuzhiyema 页码,DXFbianhao DXF," +
                "chanpintuhao 零件图号,chanpinmingcheng 零件名称,cailiao 材料,houdu 厚,changdu 长,kuandu 宽,dingdansuliang 下单数量," +
                "dantaoyongliang 单套用量,beizu 备注,gongyiliusheng 工艺流程,luodanriqi 下单日期,luodanyuan 录入人," +
                "xiugairiqi 修改日期,xiugairen 修改人,CASE WHEN cls_id='T' THEN '停用' ELSE '' END 是否停用,suhu 审核状态 FROM " +
                $"mf_sgdan WHERE shigongdanhao='{txtWONo.Text.Trim()}'";
            var ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql);

            dataGridView1.DataSource = ds.Tables[0];
            dataGridView1.Sort(dataGridView1.Columns[0], ListSortDirection.Ascending);
        }
        /// <summary>
        ///     工单号变更事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtWONo_TextChanged(object sender, EventArgs e)
        {
            if (txtWONo.Text.Length != 7)
            {
                return;
            }
            var sql =
                "SELECT b.shigongdanhao '工单号',b.dingdanhao '生产单号',b.jiaohuoqi '订单交期',b.kehu '客户',b.tuzhiyema '页码',b.chanpintuhao '产品图号'," +
                "a.xuhao '工序号',a.gongxumingcheng '工序名称',a.shengchanyuan '生产班组',ISNULL(a.wanshengsuliang,0) '完成数量',a.jgsu '加工数'," +
                "RTRIM(a.xujah) '序价号',a.xujia '序价',a.buzu '补助',a.gongsi '公式类型',ISNULL(a.hezhi,0) '件资合计',a.lururiqi '录入日期'," +
                "RTRIM(a.luruyan) '录入人',a.qiugairiqi '修改日期',RTRIM(a.qgren) '修改人',RTRIM(a.suhu) '审核状态',RTRIM(a.suren) '审核人'," +
                "(CASE a.Checked WHEN 1 THEN '已核对' ELSE '' END) '核对状态',a.Checker '核对人',a.Chkdate '核对日期' " +
                $"FROM dbo.tf_sgdantwo a LEFT JOIN dbo.mf_sgdan b ON a.shigongdanhao=b.shigongdanhao WHERE a.shigongdanhao='{txtWONo.Text.Trim()}'";
            var ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql);

            dataGridView1.DataSource = ds.Tables[0];
            dataGridView1.Sort(dataGridView1.Columns[0], ListSortDirection.Ascending);
            //OnRowDataBound = "gvWOContent_RowDataBound";
        }
示例#4
0
        /// <summary>
        ///     使用参数化登录
        /// </summary>
        /// <param name="args"></param>
        private static void LoginByArgs(string[] args)
        {
            var commandArgs = CommandLine.Parse(args);

            if (commandArgs.ArgPairs.Count <= 0)
            {
                return;
            }

            #region 获取用户参数

            var userName     = string.Empty;
            var userPassword = string.Empty;
            foreach (var pair in commandArgs.ArgPairs)
            {
                if ("U".Equals(pair.Key, StringComparison.OrdinalIgnoreCase))
                {
                    userName = pair.Value;
                }
                if ("P".Equals(pair.Key, StringComparison.OrdinalIgnoreCase))
                {
                    userPassword = pair.Value;
                }
            }

            #endregion

            //if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(identity))
            //{
            //    bool bLogin = Portal.gc.LoginByIdentity(userName.Trim(), identity);
            //    if (bLogin)
            //    {
            //        ShowMainDialog();
            //    }
            //    else
            //    {
            //        LoginNormal(args);
            //    }
            //}
            //string userName = commandArgs.ArgPairs["U"];
            //string userPassword = commandArgs.ArgPairs.ContainsKey("P") ? commandArgs.ArgPairs["P"] : "";
            if (!string.IsNullOrEmpty(userName))
            {
                //var localIp = NetworkUtil.GetLocalIP();
                //if (localIp == null) throw new ArgumentNullException("args");
                //var macAddress = HardwareInfoHelper.GetMacAddress();
                //if (macAddress == null) throw new ArgumentNullException("args");
                //if (
                //    !string.IsNullOrEmpty(BLLFactory<User>.Instance.VerifyUser(userName, userPassword, Gc.AppWholeName,
                //        localIp, macAddress)))
                //{
                //    var userByName = BLLFactory<User>.Instance.GetUserByName(userName);
                //    var functionsByUser = BLLFactory<Function>.Instance.GetFunctionsByUser(userByName.ID,
                //        Gc.AppWholeName);
                //    if ((functionsByUser != null) && (functionsByUser.Count > 0))
                //    {
                //        foreach (
                //            var functionInfo in
                //                functionsByUser.Where(
                //                    functionInfo => !Gc.FunctionDict.ContainsKey(functionInfo.ControlID)))
                //        {
                //            Gc.FunctionDict.Add(functionInfo.ControlID, functionInfo.ControlID);
                //        }
                //    }
                //    Gc.UserInfo = userByName;
                //    Gc.LoginUserInfo = Gc.ConvertToLoginUser(userByName);
                //    Cache.Instance.Add("LoginUserInfo", Gc.LoginUserInfo);
                //    Cache.Instance.Add("FunctionDict", Gc.FunctionDict);
                //    //gc.ManagedWareHouse = gc.GetWareHouse(userByName);
                //    //if ((gc.ManagedWareHouse != null) && (gc.ManagedWareHouse.Count > 0))
                //    //{
                //    Splasher.Show(typeof(FrmSplash));
                //    Gc.MainDialog = new MainForm { StartPosition = FormStartPosition.CenterScreen };
                //    Application.Run(Gc.MainDialog);
                //    //}
                //    //else
                //    //{
                //    //    MessageUtil.ShowTips("用户登录信息正确,但未授权管理库房信息,请联系管理人员授权管理");
                //    //    GetAllURL(string_0);
                //    //}
                //else
                //{
                //    MessageUtil.ShowTips("用户帐号密码不正确");
                //    LoginNormal();
                //}
                var sql = $"SELECT TOP 1 * FROM IDPASS WHERE ID='{userName}'";
                try
                {
                    var dr = SqlHelper.ExecuteReader(SqlHelper.GetConnSting(), CommandType.Text, sql);
                    if (dr.Read())
                    {
                        var pass = dr["pass"].ToString().Trim();
                        if (userPassword == pass)
                        {
                            SqlHelper.UserName = dr["name"].ToString().Trim();
                            SqlHelper.UserType = dr["leiq"].ToString().Trim();
                            SqlHelper.DeptId   = dr["DeptId"].ToString().Trim();
                            SqlHelper.UserId   = userName;

                            Splasher.Show(typeof(FrmSplash));
                            Gc.MainDialog = new MainForm {
                                StartPosition = FormStartPosition.CenterScreen
                            };
                            Application.Run(Gc.MainDialog);
                        }
                        else
                        {
                            MessageBox.Show(@"密码错误,请重新输入!", Resources.T提示);
                            LoginNormal();
                        }
                    }
                    else
                    {
                        MessageBox.Show($"此帐号< {userName} >不存在,请重新输入!!", Resources.T提示);
                    }
                    dr.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(@"数据库连接错误!" + ex.Message);
                }
            }
            else
            {
                MessageUtil.ShowTips("命令格式有误");
                LoginNormal();
            }
        }