private void 数据比较查询_Load(object sender, EventArgs e)
        {
            cmbProducts1.Items.Add("查询所有");
            var mTable = new T_ProductsTableAdapter().GetDataByLevel(1); //获取level1的产品

            foreach (销售管理.DAL.DataSetProducts.T_ProductsRow mRow in mTable.Rows)
            {
                cmbProducts1.Items.Add(new Classes.PubClass.MyCmbList(mRow.Id, mRow.Name));
            }
            cmbProducts1.SelectedIndex = 0;
            var mTable1 = new T_UsersTableAdapter().GetSalers(); //获取销售

            foreach (销售管理.DAL.DataSetUsers.T_UsersRow mRow in mTable1.Rows)
            {
                cmbUsername.Items.Add(new Classes.PubClass.MyCmbList(mRow.id, mRow.UserName));
            }
            cmbUsername.Items.Insert(0, "查询所有");
            cmbUsername.SelectedIndex    = 0;
            cmbUsername.DisplayMember    = "Name";
            cmbUsername.ValueMember      = "Id";
            rbSaler.Checked              = true;
            cmbCompareType.SelectedIndex = 0;
            dtpStart.Value = dtpStart.Value.AddMonths(-1);
            if (!Common.AuthenticateRight.AuthOperation(140301) && !CommonClass.SttUser.blSuperUser)
            {
                cmbUsername.SelectedIndex = cmbUsername.FindStringExact(Classes.PubClass.UserName.ToString());
                cmbUsername.Enabled       = false;
            }
        }
        private void 费用分配查询_Load(object sender, EventArgs e)
        {
            rbDetails.Checked = true;
            var mTable1 = new T_UsersTableAdapter().GetSalers();

            foreach (销售管理.DAL.DataSetUsers.T_UsersRow mRow in mTable1.Rows)
            {
                cmbUsername.Items.Add(new Classes.PubClass.MyCmbList(mRow.id, mRow.UserName));
            }
            cmbUsername.Items.Insert(0, "查询所有");
            cmbUsername.SelectedIndex = 0;
            cmbType.SelectedIndex     = 0;

            cmbCompanyName.ValueMember   = "Id";
            cmbCompanyName.DisplayMember = "CompanyName";
            DataTable mTable = new T_CustomersTableAdapter().GetData();

            销售管理.DAL.DataSetCustomers.T_CustomersRow mDataRow = (销售管理.DAL.DataSetCustomers.T_CustomersRow)mTable.NewRow();
            mDataRow.id          = 0;
            mDataRow.CompanyName = "全部";
            mTable.Rows.InsertAt(mDataRow, 0);
            cmbCompanyName.DataSource = mTable;

            if (!Common.AuthenticateRight.AuthOperation(140201) && !CommonClass.SttUser.blSuperUser)
            {
                cmbUsername.SelectedIndex = cmbUsername.FindStringExact(Classes.PubClass.UserName);
                cmbUsername.Enabled       = false;
                rbUserSum.Visible         = false;
                rbDepartSum.Visible       = false;
            }
        }
Example #3
0
 private void tvUsers_AfterSelect(object sender, TreeViewEventArgs e)
 {
     btnAdd.Enabled = true;
     try
     {
         DAL.DataSetUsers.T_UsersDataTable mTable = new T_UsersTableAdapter().GetDataByLoginName(tvUsers.SelectedNode.Text);
         if (mTable.Rows.Count > 0)
         {
             DAL.DataSetUsers.T_UsersRow mRow = (DAL.DataSetUsers.T_UsersRow)mTable.Rows[0];
             mId               = mRow.id;
             txtId.Text        = mRow.id.ToString();
             txtLoginName.Text = mRow.LoginName;
             txtUserName.Text  = mRow.UserName;
             //txtPass.Text = mRow.PassWord;
             //txtRePass.Text = mRow.PassWord;
             cmbRight.SelectedItem      = mRow.OperRight;
             cmbUserStatus.SelectedItem = mRow.UserStatus;
             txtUserChar.Text           = mRow.UserChar;
             btnSave.Enabled            = true;
         }
         else
         {
             MessageBox.Show("没有找到该用户的信息");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
     }
 }
Example #4
0
        private void Login_Click(object sender, EventArgs e)
        {
            T_UsersTableAdapter adapter = new T_UsersTableAdapter();
            WinForm8_强类型Login.DataSetUsers.T_UsersDataTable users =  adapter.GetDataByFUserName(txtUserName.Text);
            if (users.Count <= 0)
            {
                MessageBox.Show("用户名错误");
            }
            else
            {
                WinForm8_强类型Login.DataSetUsers.T_UsersRow user = users[0];
                if (user.FErrorTimes > 3)
                {
                    MessageBox.Show("错误次数过多");
                    return;
                }
                if (user.FPassWord == txtPassWord.Text)
                {
                    MessageBox.Show("登陆成功");
                    adapter.ResetErrorTimes(user.id);
                }
                else
                {
                    adapter.IncErrorTimesById(user.id);
                    MessageBox.Show("密码错误");
                }

            }
        }
Example #5
0
 private void btnModify_Click(object sender, EventArgs e)
 {
     if (txtOldPass.Text.Trim() == "")
     {
         toolTip1.Show("原密码不能为空!", txtOldPass, 0, txtOldPass.Height, 2000);
         return;
     }
     if (txtNewPass.Text.Trim() == "")
     {
         toolTip1.Show("新密码不能为空!", txtNewPass, 0, txtNewPass.Height, 2000);
         return;
     }
     if (txtRePass.Text.Trim() == "")
     {
         toolTip1.Show("新密码不能为空!", txtRePass, 0, txtRePass.Height, 2000);
         return;
     }
     if (txtNewPass.Text.Trim() != txtRePass.Text.Trim())
     {
         toolTip1.Show("两次密码输入不一致!", txtRePass, 0, txtRePass.Height, 2000);
         return;
     }
     try
     {
         string oldPass = txtOldPass.Text.Trim();
         oldPass = Classes.MD5.Md5Encrypt(oldPass);
         T_UsersTableAdapter adapter = new T_UsersTableAdapter();
         var mTable = adapter.GetDataByLoginName(txtLoginName.Text.Trim());
         if (mTable.Rows.Count > 0)
         {
             var mRow = (销售管理.DAL.DataSetUsers.T_UsersRow)mTable.Rows[0];
             if (oldPass != mRow.PassWord)
             {
                 MessageBox.Show("原密码输入错误");
                 return;
             }
             int ret = adapter.UpdatePass(Classes.MD5.Md5Encrypt(txtNewPass.Text.Trim()), txtLoginName.Text.Trim(), oldPass);
             if (ret > 0)
             {
                 MessageBox.Show("修改成功");
                 return;
             }
             else
             {
                 MessageBox.Show("修改失败");
                 return;
             }
         }
         else
         {
             MessageBox.Show("没有找到此用户信息");
             return;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
     }
 }
Example #6
0
        public void SetTableNo()
        {
            if (type == "个人订单" || type == "部门订单" || type == "跨区域订单")
            {
                if (oldType == "个人订单" || oldType == "部门订单" || oldType == "跨区域订单")
                {
                    txtTableNo.Text = FailTableNo;
                    return;
                }
            }
            else
            {
                if (oldType == "公司跟单")
                {
                    txtTableNo.Text = FailTableNo;
                    return;
                }
            }

            if (SalerId > 0)
            {
                string mTableNo;
                if (DeliverDate.Year.ToString() == "1")
                {
                    mTableNo = DateTime.Now.Year.ToString("0000") + DateTime.Now.Month.ToString("00");
                }
                else
                {
                    mTableNo = DeliverDate.Year.ToString("0000") + DeliverDate.Month.ToString("00");
                }
                var mTable = new T_UsersTableAdapter().GetDataById(SalerId);
                if (mTable.Rows.Count > 0)
                {
                    销售管理.DAL.DataSetUsers.T_UsersRow mRow = mTable[0];
                    string mSalerChar = mRow.UserChar;
                    if (type == "个人订单" || type == "部门订单" || type == "跨区域订单")
                    {
                        mTableNo = "RT-" + mSalerChar + mTableNo;
                        if (mSalerChar == "")
                        {
                            MessageBox.Show("请设置个人区域代码");
                            btnApply.Enabled = false;
                        }
                    }
                    else
                    {
                        mTableNo = "RT-" + mTableNo;
                    }
                    string mTable1 = new T_ExpenseAllocationTableAdapter().GetMaxTableNo(mTableNo).ToString();
                    txtTableNo.Text = mTableNo + (Convert.ToInt32(mTable1.Substring(mTable1.Length - 3, 3)) + 1).ToString("000");
                }
            }
        }
Example #7
0
 protected void txtUsername_TextChanged(object sender, EventArgs e)
 {
     T_UsersTableAdapter adapter = new T_UsersTableAdapter();
     if (adapter.GetDataByUserName(txtUsername.Text).Count >= 1)
     {
         forUsername.Text = "用户名已存在";
         forUsername.Visible = true;
         return;
     }
     else
     {
         forUsername.Visible = false;
     }
 }
Example #8
0
        protected void txtUserName_TextChanged(object sender, EventArgs e)
        {
            T_UsersTableAdapter adapter = new T_UsersTableAdapter();
            var user = adapter.GetDataByName(txtUserName.Text);

            if (user.Count > 0)
            {
                lblUserCheck.Text    = "用户名已存在,请重新输入";
                lblUserCheck.Visible = true;
                return;
            }
            else
            {
                lblUserCheck.Visible = false;
            }
        }
        private void 销售记录查询_Load(object sender, EventArgs e)
        {
            cmbProducts1.Items.Add("查询所有");
            var mTable = new T_ProductsTableAdapter().GetDataByLevel(1); //获取level1的产品

            foreach (销售管理.DAL.DataSetProducts.T_ProductsRow mRow in mTable.Rows)
            {
                cmbProducts1.Items.Add(new Classes.PubClass.MyCmbList(mRow.Id, mRow.Name));
            }
            cmbProducts1.SelectedIndex = 0;
            //获取销售列表
            var mTable1 = new T_UsersTableAdapter().GetSalers();

            foreach (销售管理.DAL.DataSetUsers.T_UsersRow mRow in mTable1.Rows)
            {
                cmbUsername.Items.Add(new Classes.PubClass.MyCmbList(mRow.id, mRow.UserName));
            }
            cmbUsername.Items.Insert(0, "查询所有");
            cmbUsername.SelectedIndex = 0;
            //获取省 不用数据绑定是因为要添加 查询所有
            cmbPromary.Items.Add("查询所有");
            var mTable2 = new T_PromaryTableAdapter().GetData();

            foreach (销售管理.DAL.DataSetPromary.T_PromaryRow mRow in mTable2.Rows)
            {
                cmbPromary.Items.Add(new Classes.PubClass.MyCmbList(mRow.proID, mRow.proName));
            }

            cmbPromary.SelectedIndex = 0;

            rbDetails.Checked = true;
            //是否开票选项
            lbInvoiceFlag.Visible  = true;
            CmbInvoiceFlag.Visible = true;

            //MakeLineChart();

            if (!Common.AuthenticateRight.AuthOperation(140101) && !CommonClass.SttUser.blSuperUser)
            {
                cmbUsername.SelectedIndex = cmbUsername.FindStringExact(Classes.PubClass.UserName);
                cmbUsername.Enabled       = false;
                rbSalerSum.Visible        = false;
            }

            //是否开票
            CmbInvoiceFlag.SelectedIndex = 0;
        }
Example #10
0
        protected void btnReg_Click(object sender, EventArgs e)
        {
            // 检查用户名是否已经存在
            T_UsersTableAdapter adapter = new T_UsersTableAdapter();
            if (adapter.GetDataByUserName(txtUsername.Text).Count >= 1)
            {
                forUsername.Text = "用户名已存在";
                forUsername.Visible = true;
                return;
            }
            else
            {
                forUsername.Visible = false;
            }

            // 检查两次密码是否一致
            if (txtPassword.Text != txtPwConfirm.Text)
            {
                Label5.Text = "两次输入的密码不一致";
                Label5.Visible = true;
                return;
            }

            //邮箱合法性验证
            Regex reMail = new Regex(@".+@.+");
            if (reMail.IsMatch(txtEmail.Text) == false)
            {
                Label6.Text = "邮箱名不合法";
                Label6.Visible = true;
                return;
            }
            else
            {
                Label6.Visible = false;
            }

            //通过校验,写入数据
            int done = adapter.Insert(txtUsername.Text, txtPassword.Text, txtEmail.Text, DateTime.Now);
            if (done == 0)
            {
                Label6.Text = "注册失败,请稍候再试";
            }
            //跳转
            Response.Redirect("showMessage.aspx?Msg=注册成功,跳转中...&RedirectURL=Default.aspx");
        }
Example #11
0
        private void 开票信息查询_Load(object sender, EventArgs e)
        {
            //获取销售列表
            var mTable1 = new T_UsersTableAdapter().GetSalers();

            foreach (销售管理.DAL.DataSetUsers.T_UsersRow mRow in mTable1.Rows)
            {
                cmbUsername.Items.Add(new Classes.PubClass.MyCmbList(mRow.id, mRow.UserName));
            }
            cmbUsername.Items.Insert(0, "查询所有");
            cmbUsername.SelectedIndex = 0;

            if (!Common.AuthenticateRight.AuthOperation(140401) && !CommonClass.SttUser.blSuperUser)
            {
                cmbUsername.SelectedIndex = cmbUsername.FindStringExact(Classes.PubClass.UserName);
                cmbUsername.Enabled       = false;
            }
        }
Example #12
0
 private void btnResetPass_Click(object sender, EventArgs e)
 {
     try
     {
         int ret = new T_UsersTableAdapter().ResetPass(Classes.MD5.Md5Encrypt("1"), mId);
         if (ret > 0)
         {
             MessageBox.Show("重置成功,密码'1'");
             tvShow();
         }
         else
         {
             MessageBox.Show("重置失败");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
     }
 }
Example #13
0
 private void btnDel_Click(object sender, EventArgs e)
 {
     try
     {
         int ret = new T_UsersTableAdapter().DeleteById(mId);
         if (ret > 0)
         {
             MessageBox.Show("删除成功");
             tvShow();
         }
         else
         {
             MessageBox.Show("删除失败");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
     }
 }
        public void ProcessRequest(HttpContext context)
        {
            if (context.Session["IsLogin"] == null)
            {
                context.Response.Redirect("Redirect2Login.html");
            }
            else
            {
                string fileName = context.Request["fileName"];

                context.Response.ContentType = "image/JPEG";
                string encodeFileName = HttpUtility.UrlEncode(fileName);
                context.Response.AddHeader("Content-Disposition", string.Format("attachment:filename=\"{0}\"", encodeFileName));

                int userId = (int)context.Session["UserId"];
                T_UsersTableAdapter adapter = new T_UsersTableAdapter();
                var data = adapter.GetDataById(userId);
                var user = data.Single();
                if (user.Type == 0)//普通用户
                {
                    using (Bitmap bitmap = new Bitmap(context.Server.MapPath("Imgs/" + fileName)))
                    {
                        using (Graphics g = Graphics.FromImage(bitmap))
                        {
                            g.DrawString("免费用户试用--" + user.UserName, new Font("宋体", 20), Brushes.Red, 0, 0);
                        }
                        bitmap.Save(context.Response.OutputStream, ImageFormat.Jpeg);//为了演示,效率不高
                    }
                }
                else//收费用户
                {
                    //http://localhost:4253/DownloadPic.ashx?fileName=../DownloadPic.ashx.cs
                    if (fileName.Contains("/"))
                    {
                        return;
                    }
                    context.Response.WriteFile("Imgs/" + fileName);//有攻击漏洞
                }
            }
        }
Example #15
0
 private void tvShow()
 {
     tvUsers.Nodes[0].Nodes.Clear();
     try
     {
         var mTable = new T_UsersTableAdapter().GetData();
         if (mTable.Rows.Count > 0)
         {
             foreach (销售管理.DAL.DataSetUsers.T_UsersRow mRow in mTable.Rows)
             {
                 if (mRow.LoginName.ToString() != "admin")
                 {
                     tvUsers.Nodes[0].Nodes.Add(mRow.LoginName.ToString());
                 }
             }
         }
         tvUsers.ExpandAll();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
     }
 }
Example #16
0
        public string oldType;        //原订单类型
        private void Form1_Load(object sender, EventArgs e)
        {
            DataTable mTable1  = new T_ExpenseAllocationTableAdapter().GetDataById(ExId);
            var       mDataRow = (销售管理.DAL.DataSetExpenseAllocation.T_ExpenseAllocationRow)mTable1.Rows[0];

            //cmbMonth.SelectedItem = mDataRow.Month;
            //txtTableNo.Text = mDataRow.TableNo;
            //txtCustomerName.Text = mDataRow.CustomerName;
            txtProjectName.Text = mDataRow.ProjectName;
            var mProductTable = new T_ProductsTableAdapter().GetDataByID(mDataRow.ProductName);

            if (mProductTable.Rows.Count > 0)
            {
                txtProductName.Text = mProductTable[0].Name;
            }
            var mCustomerTable = new T_CustomersTableAdapter().GetDataById(Convert.ToInt64(mDataRow.CustomerName));

            if (mProductTable.Rows.Count > 0)
            {
                txtCustomerName.Text = mCustomerTable[0].CompanyName;
            }
            txtProductName.Tag      = mDataRow.ProductName;
            txtCustomerName.Tag     = mDataRow.CustomerName;
            txtType.Text            = mDataRow.ProductType;
            txtAmount.Text          = mDataRow.Amount.ToString();
            txtDeliverPrice.Text    = mDataRow.DeliverPrice.ToString();
            txtDeliverSum.Text      = mDataRow.DeliverSum.ToString();
            txtSalePrice.Text       = mDataRow.SalePrice.ToString();
            txtSaleSum.Text         = mDataRow.SaleSum.ToString();
            txtSaleWages.Text       = mDataRow.SaleWages.ToString();
            txtCommissionPrice.Text = mDataRow.CommissionPrice.ToString();
            txtCommissionSum.Text   = mDataRow.CommissionSum.ToString();
            txtSaleCommission.Text  = mDataRow.SaleComission.ToString();
            txtAgentPrice.Text      = mDataRow.AgentPrice.ToString();
            txtAgentSum.Text        = mDataRow.AgentSum.ToString();
            txtAgentCommission.Text = mDataRow.AgentCommission.ToString();

            SalerId = mDataRow.UserName;
            DataTable mTable = new T_UsersTableAdapter().GetDataById(SalerId);

            if (mTable.Rows.Count > 0)
            {
                var mDataRow1 = (销售管理.DAL.DataSetUsers.T_UsersRow)mTable.Rows[0];
                txtUserName.Text = mDataRow1.UserName;
            }

            if (mDataRow.type == "个人订单")
            {
                rbPersonal.Checked = true;
            }
            else if (mDataRow.type == "部门订单")
            {
                rbDepart.Checked = true;
            }
            else if (mDataRow.type == "公司跟单")
            {
                rbCompany.Checked = true;
            }
            else
            {
                rbCity.Checked = true;
            }
            if (mDataRow.IsCitySalerNull() == false)
            {
                if (mDataRow.CitySaler != "0")
                {
                    cmbUserName.SelectedValue = Convert.ToInt64(mDataRow.CitySaler);
                }
            }
            oldType         = mDataRow.type;
            FailTableNo     = mDataRow.TableNo;
            txtTableNo.Text = mDataRow.TableNo;

            if (mDataRow.IsPaid == "已付款")
            {
                cbIsPaid.Checked = true;
            }
            else
            {
                cbIsPaid.Checked = false;
            }
            if (mDataRow.IsPaidDateNull() == false)
            {
                dtpPaidDate.Value = mDataRow.PaidDate;
            }

            txtStatus.Text = mDataRow.Status;        //+"。" + mDataRow.BusinessRemark;

            labStatus.Visible = true;
            txtStatus.Visible = true;
            btnApply.Enabled  = true;

            if (mDataRow.Status.Contains("不通过") == true && isModify == true)
            {
                btnApply.Enabled = true;
                btnApply.Text    = "重新申请";
            }
            else
            {
                btnApply.Enabled = true;
            }
            //groupBox1.Enabled = false;
        }
Example #17
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (cmbUsers.Text == string.Empty)
            {
                toolTip1.Show("请选择领用人!", cmbUsers, 0, cmbUsers.Height, 2000);
                return;
            }
            if (CBoxUser.Text == string.Empty)
            {
                toolTip1.Show("请选择使用人!", CBoxUser, 0, CBoxUser.Height, 2000);
                return;
            }
            if (cmbCustomers.Text == string.Empty)
            {
                toolTip1.Show("请选择客户名称!", cmbCustomers, 0, cmbCustomers.Height, 2000);
                return;
            }
            if (cmbGifts.Text == string.Empty)
            {
                toolTip1.Show("请选择礼品名称!", cmbGifts, 0, cmbGifts.Height, 2000);
                return;
            }
            if (txtCurrentNum.Text == string.Empty)
            {
                toolTip1.Show("请输入领用用量!", txtCurrentNum, 0, txtCurrentNum.Height, 2000);
                return;
            }
            long mNewGiftId = Convert.ToInt64(cmbGifts.SelectedValue);

            if (mId == -1 || mNewGiftId != mOldGiftId)//新增
            {
                if (Convert.ToDecimal(txtCurrentNum.Text) > Convert.ToDecimal(txtStockNum.Text))
                {
                    toolTip1.Show("领用数量不得大于库存数量!", txtCurrentNum, 0, txtCurrentNum.Height, 2000);
                    return;
                }
            }
            else
            {//修改
                if ((Convert.ToDecimal(txtCurrentNum.Text) - mOldNum) > Convert.ToDecimal(txtStockNum.Text))
                {
                    toolTip1.Show("领用数量不得大于库存数量!", txtCurrentNum, 0, txtCurrentNum.Height, 2000);
                    return;
                }
            }

            string    operRight  = "";
            DataTable mTempTable = new T_UsersTableAdapter().GetDataById(Convert.ToInt64(cmbUsers.SelectedValue));

            销售管理.DAL.DataSetUsers.T_UsersRow mRow;
            if (mTempTable.Rows.Count > 0)
            {
                mRow      = (销售管理.DAL.DataSetUsers.T_UsersRow)mTempTable.Rows[0];
                operRight = mRow.OperRight;
            }
            //if (Convert.ToDecimal(txtSum.Text) - mOldSum > Convert.ToDecimal(txtMaxSum.Text) && operRight != "领导" && operRight != "融通创投" && operRight != "金融卡事业部" && operRight != "财务")
            //{
            //    toolTip1.Show("领用礼品金额不能超过最大允许金额!", txtMaxSum, 0, txtMaxSum.Height, 2000);
            //    return;
            //}


            //修改时间:2016/8/8 修改内容:添加销售角色剩余额度判断
            #region
            if (operRight == "销售" && Convert.ToDecimal(txtMaxSum.Text) - Convert.ToDecimal(txtSum.Text) < -5000)
            {
                MessageBox.Show("剩余额度已超5000元,礼品出库申请提交失败!", "超额提醒");
                return;
            }
            #endregion



            try
            {
                decimal mCurrentNum = Convert.ToDecimal(txtCurrentNum.Text);
                txtCurrentNum_TextChanged(sender, e);
                decimal mSum = Convert.ToDecimal(txtSum.Text);


                using (SqlConnection mConn = new SqlConnection(Common.CommonClass.SqlConnStr))
                {
                    mConn.Open();
                    using (SqlTransaction mTrans = mConn.BeginTransaction())
                    {
                        try
                        {
                            if (mId < 0)
                            {//插入
                                var adapter = new T_GiftStockOutTableAdapter();
                                adapter.Connection  = mConn;
                                adapter.Transaction = mTrans;
                                int ret = 0;
                                ret = adapter.Insert(dtpDataDate.Value.Date.ToString(), Convert.ToInt64(cmbUsers.SelectedValue), Convert.ToInt64(cmbCustomers.SelectedValue), Convert.ToInt64(cmbGifts.SelectedValue), cmbGifts.Text, mCurrentNum, Convert.ToDecimal(txtGiftPrice.Text), mSum, "已提交等待领导审核", null, null, Classes.PubClass.UserId, Convert.ToInt64(CBoxUser.SelectedValue));
                                //if (ret > 0)
                                //{
                                //    var adapter1 = new T_GiftsTableAdapter();
                                //    adapter1.Connection = mConn;
                                //    adapter1.Transaction = mTrans;

                                //    ret = adapter1.AddStockNum(-mCurrentNum, Convert.ToInt64(cmbGifts.SelectedValue));
                                if (ret > 0)
                                {
                                    mTrans.Commit();
                                    MessageBox.Show("插入成功");
                                    btnSave.Enabled = false;
                                    return;
                                }
                                else
                                {
                                    mTrans.Rollback();
                                    MessageBox.Show("插入失败:2");
                                    return;
                                }

                                //}
                                //else
                                //{
                                //    mTrans.Rollback();
                                //    MessageBox.Show("插入失败:1");
                                //    return;
                                //}
                            }
                            else
                            {//修改
                                //先修改记录信息
                                var adapter = new T_GiftStockOutTableAdapter();
                                adapter.Connection  = mConn;
                                adapter.Transaction = mTrans;

                                int ret = 0;
                                ret = adapter.UpdateById(dtpDataDate.Value.Date, Convert.ToInt64(cmbUsers.SelectedValue), Convert.ToInt64(cmbCustomers.SelectedValue), Convert.ToInt64(cmbGifts.SelectedValue), cmbGifts.Text.ToString(), mCurrentNum, Convert.ToDecimal(txtGiftPrice.Text), mSum, Classes.PubClass.UserId, Convert.ToInt64(CBoxUser.SelectedValue), mId);

                                if (ret > 0)
                                {
                                    if (hasStockOut == true)
                                    {
                                        if (mCurrentNum != mOldNum || mOldGiftId != mNewGiftId)
                                        {
                                            var adapter1 = new T_GiftsTableAdapter();
                                            adapter1.Connection  = mConn;
                                            adapter1.Transaction = mTrans;

                                            ret = adapter1.AddStockNum(mOldNum, mOldGiftId);
                                            if (ret > 0)
                                            {
                                                ret = adapter1.AddStockNum(-mCurrentNum, mNewGiftId);
                                                if (ret < 1)
                                                {
                                                    mTrans.Rollback();
                                                    MessageBox.Show("修改数量失败:2");
                                                    return;
                                                }
                                            }
                                            else
                                            {
                                                mTrans.Rollback();
                                                MessageBox.Show("修改数量失败:1");
                                                return;
                                            }
                                        }
                                    }
                                    mTrans.Commit();
                                    MessageBox.Show("保存成功!");
                                    btnSave.Enabled = false;
                                }
                                else
                                {
                                    mTrans.Rollback();
                                    MessageBox.Show("修改失败:1");
                                    return;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            mTrans.Rollback();
                            MessageBox.Show(ex.Message);
                            return;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
        }
Example #18
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int ret = 0;

            btnAdd.Enabled = true;

            if (txtLoginName.Text.Trim() == "")
            {
                toolTip1.Show("登录名不能为空", txtLoginName, 0, txtLoginName.Height, 2000);
                return;
            }
            if (txtUserName.Text.Trim() == "")
            {
                toolTip1.Show("用户名不能为空", txtUserName, 0, txtUserName.Height, 2000);
                return;
            }
            //if (txtPass.Text.Trim() == "")
            //{
            //    toolTip1.Show("密码不能为空", txtPass, 0, txtPass.Height, 2000);
            //    return;
            //}
            //if (txtRePass.Text.Trim() == "")
            //{
            //    toolTip1.Show("确认密码不能为空", txtRePass, 0, txtRePass.Height, 2000);
            //    return;
            //}
            //if (txtPass.Text.Trim() != txtRePass.Text.Trim())
            //{
            //    toolTip1.Show("两次密码不一致", txtRePass, 0, txtRePass.Height, 2000);
            //    return;
            //}

            try
            {
                if (mId >= 0)
                {
                    T_UsersTableAdapter adapter = new T_UsersTableAdapter();
                    var mTable = adapter.GetDataByLoginName(txtLoginName.Text.Trim());
                    if (mTable.Rows.Count > 0)
                    {
                        var mRow = (销售管理.DAL.DataSetUsers.T_UsersRow)mTable.Rows[0];
                        if (mRow.id != mId)
                        {
                            MessageBox.Show("此登录名已存在!");
                            txtLoginName.Focus();
                            txtLoginName.SelectionStart  = 0;
                            txtLoginName.SelectionLength = txtLoginName.Text.Length;
                            return;
                        }
                    }

                    ret = adapter.UpdateById(txtLoginName.Text.Trim(), txtUserName.Text.Trim(), cmbRight.Text, txtUserChar.Text.Trim(), cmbUserStatus.Text, mId);
                    if (ret > 0)
                    {
                        MessageBox.Show("修改成功");
                        tvShow();
                    }
                    else
                    {
                        MessageBox.Show("修改失败");
                    }
                }
                else
                {
                    T_UsersTableAdapter adapter = new T_UsersTableAdapter();
                    var mTable = adapter.GetDataByLoginName(txtLoginName.Text.Trim());
                    if (mTable.Rows.Count > 0)
                    {
                        MessageBox.Show("此登录名已存在!");
                        txtLoginName.Focus();
                        txtLoginName.SelectionStart  = 0;
                        txtLoginName.SelectionLength = txtLoginName.Text.Length;
                        return;
                    }
                    ret = adapter.Insert(txtLoginName.Text.Trim(), Classes.MD5.Md5Encrypt("1"), txtUserName.Text.Trim(), cmbRight.Text, cmbRight.Text, txtUserChar.Text.Trim(), cmbUserStatus.Text, 0, 0);
                    if (ret > 0)
                    {
                        MessageBox.Show("添加成功");
                        tvShow();
                        btnSave.Enabled = false;
                    }
                    else
                    {
                        MessageBox.Show("添加失败");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (cmbUsers.Text == string.Empty)
                {
                    toolTip1.Show("请选择领用人!", cmbUsers, 0, cmbUsers.Height, 2000);
                    return;
                }
                if (CBoxUsed.Text == string.Empty)
                {
                    toolTip1.Show("请选择使用人!", CBoxUsed, 0, CBoxUsed.Height, 2000);
                    return;
                }
                if (cmbCustomers.Text == string.Empty)
                {
                    toolTip1.Show("请选择客户名称!", cmbCustomers, 0, cmbCustomers.Height, 2000);
                    return;
                }
                if (cmbCard.Text == string.Empty)
                {
                    toolTip1.Show("请选择消费卡!", cmbCard, 0, cmbCard.Height, 2000);
                    return;
                }
                if (txtMealMoney.Text.Trim() == string.Empty)
                {
                    toolTip1.Show("请输入消费金额!", txtMealMoney, 0, txtMealMoney.Height, 2000);
                    return;
                }
                Decimal mealMoney = 0, maxMoney = 0, cardBalance = 0;
                if (decimal.TryParse(txtMealMoney.Text, out mealMoney) == false)
                {
                    toolTip1.Show("请输入正确的消费金额", txtMealMoney, 0, txtMealMoney.Height, 2000);
                    return;
                }
                maxMoney    = Convert.ToDecimal(txtMaxSum.Text);
                cardBalance = Convert.ToDecimal(txtCardBalance.Text);

                //if(mId!=-1 || oldCardId !=Convert.ToInt64(cmbCard.SelectedValue))
                //{
                //    //新增或换消费卡
                //    if (mealMoney > cardBalance)
                //    {
                //        toolTip1.Show("消费金额不能大于消费卡内剩余金额", txtCardBalance, 0, txtCardBalance.Height, 2000);
                //        return;
                //    }
                //}
                //else
                //{
                //    if (mealMoney-oldMealMoney > cardBalance)
                //    {
                //        toolTip1.Show("消费金额不能大于消费卡内剩余金额加原消费额", txtCardBalance, 0, txtCardBalance.Height, 2000);
                //        return;
                //    }
                //}


                long   userid     = Convert.ToInt64(cmbUsers.SelectedValue);
                string userRight  = "";
                var    mUserTable = new T_UsersTableAdapter().GetDataById(userid);
                if (mUserTable.Rows.Count > 0)
                {
                    var mUserRow = mUserTable[0];
                    userRight = mUserRow.OperRight.Trim();
                }
                else
                {
                    MessageBox.Show("查找用户权限失败!");
                    return;
                }


                if (cmbCard.Text == "现金")
                {
                    if (mealMoney - oldMealMoney > maxMoney && (!Common.AuthenticateRight.AuthOperation(110609) && !CommonClass.SttUser.blSuperUser))
                    {
                        toolTip1.Show("消费金额不能大于剩余额度", txtMealMoney, 0, txtMealMoney.Height, 2000);
                        return;
                    }
                }


                //修改日期2016/8/8   添加超额提醒
                if ((maxMoney - mealMoney) < -5000)
                {
                    DialogResult dr;
                    dr = MessageBox.Show("剩余额度已超5000元,是否继续报销", "超额提醒", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                    if (dr == DialogResult.No)
                    {
                        return;
                    }
                }


                //数据库操作
                #region

                using (SqlConnection mConn = new SqlConnection(Common.CommonClass.SqlConnStr))
                {
                    mConn.Open();
                    using (SqlTransaction mTrans = mConn.BeginTransaction())
                    {
                        try
                        {
                            if (mId < 0)
                            {
                                //插入
                                var adapter = new T_MealsTableAdapter();
                                adapter.Connection  = mConn;
                                adapter.Transaction = mTrans;
                                int    ret    = 0;
                                string status = "现金";
                                if (cmbCard.Text != "现金")
                                {
                                    status = "已提交等待领导审核";
                                }
                                //添加餐费报销记录

                                ret = adapter.Insert(dtpDataDate.Value.Date, Convert.ToInt64(cmbUsers.SelectedValue), Convert.ToInt64(cmbCustomers.SelectedValue), Convert.ToInt64(cmbCard.SelectedValue), mealMoney, Classes.PubClass.UserId, status, Convert.ToInt64(CBoxUsed.SelectedValue));
                                if (ret > 0)
                                {
                                    //var adapter1 = new T_CardsTableAdapter();
                                    //adapter1.Connection = mConn;
                                    //adapter1.Transaction = mTrans;

                                    //ret = adapter1.ExpenseById(mealMoney, Convert.ToInt64(cmbCard.SelectedValue));
                                    if (ret > 0)
                                    {
                                        mTrans.Commit();
                                        MessageBox.Show("插入成功");
                                        btnSave.Enabled = false;
                                    }
                                    else
                                    {
                                        mTrans.Rollback();
                                        MessageBox.Show("插入失败:2");
                                        return;
                                    }
                                }
                                else
                                {
                                    mTrans.Rollback();
                                    MessageBox.Show("插入失败:1");
                                    return;
                                }
                            }
                            else
                            {
                                //修改
                                var adapter = new T_MealsTableAdapter();
                                adapter.Connection  = mConn;
                                adapter.Transaction = mTrans;
                                int  ret       = 0;
                                long newCardId = Convert.ToInt64(cmbCard.SelectedValue);
                                ret = adapter.UpdateById(dtpDataDate.Value.Date, Convert.ToInt64(cmbUsers.SelectedValue), Convert.ToInt64(cmbCustomers.SelectedValue), newCardId, mealMoney, Classes.PubClass.UserId, Convert.ToInt64(CBoxUsed.SelectedValue), mId);

                                if (ret > 0)
                                {
                                    //修改已完成的申请
                                    if (oldStatus == "已还卡" || oldStatus == "现金")
                                    {
                                        if (oldCardId != newCardId || oldMealMoney != mealMoney)
                                        {
                                            var adapter1 = new T_CardsTableAdapter();
                                            adapter1.Connection  = mConn;
                                            adapter1.Transaction = mTrans;
                                            if (oldCardName != "现金")
                                            {
                                                //旧消费方式为卡
                                                ret = adapter1.ExpenseById(-oldMealMoney, oldCardId);
                                            }
                                            if (ret > 0)
                                            {
                                                if (cmbCard.Text != "现金")
                                                {
                                                    //新消费方式为消费卡
                                                    ret = adapter1.ExpenseById(mealMoney, newCardId);
                                                    adapter.UpdateStatus("已还卡", mId);
                                                }
                                                else
                                                {
                                                    adapter.UpdateStatus("现金", mId);
                                                }
                                                if (ret > 0)
                                                {
                                                    mTrans.Commit();
                                                    MessageBox.Show("修改成功");
                                                    btnSave.Enabled = false;
                                                    return;
                                                }
                                                else
                                                {
                                                    mTrans.Rollback();
                                                    MessageBox.Show("修改失败:3");
                                                    return;
                                                }
                                            }
                                            else
                                            {
                                                mTrans.Rollback();
                                                MessageBox.Show("修改失败:2");
                                                return;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        //未完成的申请
                                        mTrans.Commit();
                                        MessageBox.Show("修改成功");
                                        btnSave.Enabled = false;
                                        return;
                                    }

                                    //}
                                }
                                else
                                {
                                    mTrans.Rollback();
                                    MessageBox.Show("修改失败:1");
                                    return;
                                }
                            }
                        }


                        catch (Exception ex)
                        {
                            mTrans.Rollback();
                            MessageBox.Show(ex.Message);
                            return;
                        }
                    }
                }


                #endregion
            }



            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
        }
Example #20
0
        public DateTime DeliverDate;  //发货日期

        private void 申请费用分配_Load(object sender, EventArgs e)
        {
            rbPersonal.Checked = true;
            isLoading          = true;


            if (ExId > -1)   //如果费用分配ID大于-1,查看费用分配信息
            {
                DataTable mTable1 = new T_ExpenseAllocationTableAdapter().GetDataById(ExId);
                if (mTable1.Rows.Count > 0)
                {
                    var mDataRow = (销售管理.DAL.DataSetExpenseAllocation.T_ExpenseAllocationRow)mTable1.Rows[0];
                    //cmbMonth.SelectedItem = mDataRow.Month;
                    //txtTableNo.Text = mDataRow.TableNo;
                    //txtCustomerName.Text = mDataRow.CustomerName;
                    txtProjectName.Text = mDataRow.ProjectName;
                    var mProductTable = new T_ProductsTableAdapter().GetDataByID(mDataRow.ProductName);
                    if (mProductTable.Rows.Count > 0)
                    {
                        txtProductName.Text = mProductTable[0].Name;
                    }
                    var mCustomerTable = new T_CustomersTableAdapter().GetDataById(Convert.ToInt64(mDataRow.CustomerName));
                    if (mProductTable.Rows.Count > 0)
                    {
                        txtCustomerName.Text = mCustomerTable[0].CompanyName;
                    }

                    var mSaleDetailsTable = new T_SaleDetailsTableAdapter().GetDataByExId(ExId);
                    if (mSaleDetailsTable.Rows.Count > 0)
                    {
                        DeliverDate = mSaleDetailsTable[0].SaleDate;
                    }
                    txtProductName.Tag      = mDataRow.ProductName;
                    txtCustomerName.Tag     = mDataRow.CustomerName;
                    txtType.Text            = mDataRow.ProductType;
                    txtAmount.Text          = mDataRow.Amount.ToString();
                    txtDeliverPrice.Text    = mDataRow.DeliverPrice.ToString();
                    txtDeliverSum.Text      = mDataRow.DeliverSum.ToString();
                    txtSalePrice.Text       = mDataRow.SalePrice.ToString();
                    txtSaleSum.Text         = mDataRow.SaleSum.ToString();
                    txtSaleWages.Text       = mDataRow.SaleWages.ToString();
                    txtCommissionPrice.Text = mDataRow.CommissionPrice.ToString();
                    txtCommissionSum.Text   = mDataRow.CommissionSum.ToString();
                    txtSaleCommission.Text  = mDataRow.SaleComission.ToString();
                    txtAgentPrice.Text      = mDataRow.AgentPrice.ToString();
                    txtAgentSum.Text        = mDataRow.AgentSum.ToString();
                    txtAgentCommission.Text = mDataRow.AgentCommission.ToString();

                    SalerId = mDataRow.UserName;
                    DataTable mTable = new T_UsersTableAdapter().GetDataById(SalerId);
                    if (mTable.Rows.Count > 0)
                    {
                        var mDataRow1 = (销售管理.DAL.DataSetUsers.T_UsersRow)mTable.Rows[0];
                        txtUserName.Text = mDataRow1.UserName;
                    }

                    if (mDataRow.type == "个人订单")
                    {
                        rbPersonal.Checked = true;
                    }
                    else if (mDataRow.type == "部门订单")
                    {
                        rbDepart.Checked = true;
                    }
                    else if (mDataRow.type == "公司跟单")
                    {
                        rbCompany.Checked = true;
                    }
                    else
                    {
                        rbCity.Checked = true;
                    }
                    if (mDataRow.IsCitySalerNull() == false)
                    {
                        if (mDataRow.CitySaler != "0")
                        {
                            cmbUserName.SelectedValue = Convert.ToInt64(mDataRow.CitySaler);
                        }
                    }
                    txtCitySum.Text   = mDataRow.CitySum;
                    txtCityWages.Text = mDataRow.CityWages;
                    if (mDataRow.IsCitySalePriceNull() == false)
                    {
                        txtCitySalePrice.Text = mDataRow.CitySalePrice.ToString();
                    }
                    if (mDataRow.IsCitySaleSumNull() == false)
                    {
                        txtCitySaleSum.Text = mDataRow.CitySaleSum.ToString();
                    }
                    if (mDataRow.IsCitySaleCommissionNull() == false)
                    {
                        txtCitySaleCommission.Text = mDataRow.CitySaleCommission.ToString();
                    }
                    oldType         = mDataRow.type;
                    FailTableNo     = mDataRow.TableNo;
                    txtTableNo.Text = mDataRow.TableNo;

                    if (mDataRow.IsPaid == "已付款")
                    {
                        cbIsPaid.Checked = true;
                        if (mDataRow.IsPaidDateNull() == false)
                        {
                            dtpPaidDate.Value = mDataRow.PaidDate;
                        }
                    }
                    else
                    {
                        cbIsPaid.Checked = false;
                    }

                    if (mDataRow.IsHasTaxNull() == false)
                    {
                        if (mDataRow.HasTax == "含税")
                        {
                            cbTax.Checked = true;
                        }
                        else
                        {
                            cbTax.Checked = false;
                        }
                    }
                    else
                    {
                        cbTax.Checked = false;
                    }
                    txtStatus.Text = mDataRow.Status;//+"。" + mDataRow.BusinessRemark;

                    labStatus.Visible = true;
                    txtStatus.Visible = true;
                    btnApply.Enabled  = false;
                    //label12.Visible = true;
                    //dtpPaidDate.Visible = true;
                    cbIsPaid.Visible = true;

                    if (mDataRow.Status.Contains("不通过") == true && isModify == true)
                    {
                        btnApply.Enabled = true;
                        btnApply.Text    = "重新申请";
                        cbIsPaid.Visible = false;
                    }
                    else
                    {
                        btnApply.Enabled = false;
                    }
                    //groupBox1.Enabled = false;
                }
                else
                {
                    MessageBox.Show("该费用分配表号不存在");
                    this.Close();
                    return;
                }

                if (Classes.PubClass.UserRight == "领导" || Classes.PubClass.UserRight == "超级管理员" || Classes.PubClass.UserRight == "商务经理")
                {
                    btnModifyPaid.Visible = true;
                }
                else
                {
                    btnModifyPaid.Visible = false;
                }
            }
            else  //申请费用分配
            if (mRow != null)
            {
                DeliverDate          = Convert.ToDateTime(mRow.Cells["saleDateDataGridViewTextBoxColumn"].Value);
                txtCustomerName.Text = mRow.Cells["customerNameDataGridViewTextBoxColumn"].Value.ToString();
                txtProductName.Text  = mRow.Cells["productNameDataGridViewTextBoxColumn"].Value.ToString();
                txtAmount.Text       = mRow.Cells["amountDataGridViewTextBoxColumn"].Value.ToString();
                //cmbMonth.SelectedItem = mRow.Cells["saleMonthDataGridViewTextBoxColumn"].Value.ToString();
                txtDeliverPrice.Text = mRow.Cells["priceDataGridViewTextBoxColumn"].Value.ToString();
                long SaleDetailsId    = Convert.ToInt64(mRow.Cells["idDataGridViewTextBoxColumn"].Value);
                var  SaleDetailsTable = new T_SaleDetailsTableAdapter().GetDataById(SaleDetailsId);
                if (SaleDetailsTable.Rows.Count > 0)
                {
                    txtProductName.Tag  = SaleDetailsTable[0].ProductName;
                    txtCustomerName.Tag = SaleDetailsTable[0].CustomerName;
                    SalerId             = SaleDetailsTable[0].UserName;
                    var mUserTable = new T_UsersTableAdapter().GetDataById(SalerId);
                    if (mUserTable.Rows.Count > 0)
                    {
                        txtUserName.Text = mUserTable[0].UserName;
                    }
                    SetTableNo();
                }
                btnModifyPaid.Visible = false;
            }

            isLoading = false;
        }
Example #21
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            T_UsersTableAdapter adapter = new T_UsersTableAdapter();
            var data = adapter.GetDataByName(txtUserName.Text);

            if (data.Count <= 0)
            {
                lblErrorMsg.Text    = "查无此人";
                lblErrorMsg.Visible = true;
            }
            else
            {
                var user = data.Single();                                    //linq中的single方法,返回唯一一条数据,如果数据为0或多条,则抛出异常
                if (!user.IsErrorTimesNull() && !user.IsLastErrorTimeNull()) //判断是否不为空
                {
                    double timespan = (DateTime.Now - user.LastErrorTime).TotalMinutes;
                    if (user.ErrorTimes > 5 && timespan <= 30)
                    {
                        lblErrorMsg.Text    = "密码错误次数超过五次,请半个小时后再登录";
                        lblErrorMsg.Visible = true;
                        //btnLogin.Visible = false;
                        return;
                    }
                }

                if (user.Password == txtPassword.Text)
                {
                    adapter.ResetErrorTimes(user.Id);
                    //adapter.Update(user);
                    Session["IsLogin"] = true;
                    Session["UserId"]  = user.Id;
                    //lblErrorMsg.Text = "登录成功";
                    //lblErrorMsg.Visible = true;
                    //登录成功,将用户重定向到download图片页面
                    Response.Redirect("Download.html");
                    //重定向到下载页面
                }
                else
                {
                    //if (string.IsNullOrEmpty(user.LastErrorTime.ToString()) || string.IsNullOrEmpty(user.ErrorTimes.ToString()) || user.ErrorTimes == 0)
                    //{
                    //    user.LastErrorTime = DateTime.Now;
                    //    user.ErrorTimes = 0;
                    //}

                    //DateTime lastErrorTime = user.LastErrorTime;
                    //DateTime nowTime = DateTime.Now;
                    //TimeSpan timespan = nowTime - lastErrorTime;
                    //if (timespan.Seconds < 1800)
                    //{
                    //    user.LastErrorTime = nowTime;
                    //    user.ErrorTimes = user.ErrorTimes + 1;

                    //}

                    user.LastErrorTime = DateTime.Now;
                    user.ErrorTimes    = user.ErrorTimes + 1;
                    adapter.Update(user);

                    lblErrorMsg.Text    = "密码错误,登录失败";
                    lblErrorMsg.Visible = true;
                }
            }
        }