Example #1
0
 private void ProductCode_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         ProductName.Focus();
     }
 }
 public AddProduct()
 {
     InitializeComponent();
     this.PreviewKeyDown += new KeyEventHandler(HandleEsc);
     this.DataContext     = new ProductViewModel();
     ProductName.Focus();
 }
Example #3
0
        private void SaveData(bool close)
        {
            // 设置鼠标繁忙状态,并保留原先的状态
            Cursor holdCursor = this.Cursor;

            this.Cursor = Cursors.WaitCursor;
            //读取产品实体数据
            this.GetDataEntity();

            if (new ProductInfoManager(dbProvider, this.UserInfo).Exists(new[] { ProductInfoTable.FieldProductCode, ProductInfoTable.FieldProductName, ProductInfoTable.FieldDeleteMark }
                                                                         , new object[] { productInfoEntity.ProductCode, productInfoEntity.ProductName, "0" }))
            {
                MessageBoxHelper.ShowWarningMsg("库中已经存在相同数据,请重新检查输入!");
                ProductName.Focus();
            }
            else
            {
                string returnValue = new ProductInfoManager(dbProvider, this.UserInfo).AddEntity(productInfoEntity);
                if (returnValue.Trim().Length > 0)
                {
                    this.Changed = true;
                    MessageBoxHelper.ShowSuccessMsg("新增成功!");
                }
                else
                {
                    MessageBoxHelper.ShowWarningMsg("新增数据失败!");
                }
            }

            // 设置鼠标默认状态,原来的光标状态
            this.Cursor = holdCursor;

            if (this.Changed && close)
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
                if (OnFormClosedRefreash != null)
                {
                    OnFormClosedRefreash();
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ToString());
            //panelcheque.Visible = false;
            //  panel2.Visible = false;
            // Button2.Visible = false;

            //Panel3.Visible = false;
            //  panel5.Visible = false;
            // panel4.Visible = false;
            // panel6.Visible = false;
            if (!IsPostBack)
            {
                // ProductName.Focus();
                ProductName.Focus();
                DataTable dt = new DataTable();
                dt.Columns.Add("ID");       /*0*/
                dt.Columns.Add("Name");     /*1*/
                dt.Columns.Add("MRP");      /*2*/
                dt.Columns.Add("DP");       /*3*/
                dt.Columns.Add("BV");       /*4*/
                dt.Columns.Add("CGST");     /*5*/
                dt.Columns.Add("SGST");     /*6*/
                dt.Columns.Add("IGST");     /*7*/
                dt.Columns.Add("Cess");     /*8*/
                dt.Columns.Add("Tax");      /*9*/
                dt.Columns.Add("Qty");      /*10*/
                dt.Columns.Add("Amount");   /*11*/
                dt.Columns.Add("CashBack"); /*12*/
                dt.Columns.Add("Discount"); /*13*/

                ViewState["DT"]        = dt;
                Button4.Visible        = false;
                CashBack.Visible       = false;
                txtselcashback.Visible = false;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Redirect("UserHome.aspx");

            con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ToString());
            //panelcheque.Visible = false;
            //  panel2.Visible = false;
            Button2.Visible = false;

            //Panel3.Visible = false;
            //  panel5.Visible = false;
            // panel4.Visible = false;
            // panel6.Visible = false;
            if (!IsPostBack)
            {
                // ProductName.Focus();
                ProductName.Focus();
                DataTable dt = new DataTable();
                dt.Columns.Add("ID");
                dt.Columns.Add("Name");
                dt.Columns.Add("MRP");
                dt.Columns.Add("DP");
                dt.Columns.Add("BV");
                dt.Columns.Add("CGST");
                dt.Columns.Add("SGST");
                dt.Columns.Add("IGST");
                dt.Columns.Add("Tax");
                dt.Columns.Add("Qty");
                dt.Columns.Add("Amount");
                dt.Columns.Add("CashBack");
                dt.Columns.Add("Discount");
                ViewState["DT"]        = dt;
                Button4.Visible        = false;
                CashBack.Visible       = false;
                txtselcashback.Visible = false;
            }
        }
 public AddStock()
 {
     InitializeComponent();
     this.PreviewKeyDown += new KeyEventHandler(HandleEsc);
     ProductName.Focus();
 }
        protected void Button1_Click(object sender, EventArgs e)
        {
            con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ToString());


            DataTable dt = (DataTable)ViewState["DT"];
            decimal   Balance;

            foreach (DataRow item in dt.Rows)
            {
                // if (item[0].ToString() == PID.Value)
                if (item[0].ToString() == ProductCode.Text)
                {
                    item[0] = ProductCode.Text;
                    string abc = item[10].ToString();
                    string qty = Qty.Text;

                    string pqr    = item[10].ToString();
                    string amount = Amount.Text;
                    item[10] = (decimal.Parse(abc) + decimal.Parse(qty)).ToString();
                    item[4]  = Decimal.Parse(BV.Text);
                    item[11] = (decimal.Parse(pqr) + decimal.Parse(amount)).ToString();

                    dt.Rows[0].EndEdit();
                    dt.AcceptChanges();

                    GridView1.DataSource = dt;
                    GridView1.DataBind();

                    CalcTotals();
                    ProductName.Text = "";
                    ProductCode.Text = "";
                    MRP.Text         = "";
                    DP.Text          = "";
                    BV.Text          = "";
                    Qty.Text         = "";
                    Tax.Text         = "";
                    Amount.Text      = "";
                    Cess.Text        = "";
                    //ProductCode.Focus();
                    ProductName.Focus();
                    return;
                }
            }
            DataRow row = dt.NewRow();

            row[0] = ProductCode.Text;
            row[1] = ProductName.Text;
            row[2] = (Math.Round(decimal.Parse(MRP.Text), 2).ToString());
            row[3] = (Math.Round(decimal.Parse(DP.Text), 2).ToString());
            row[4] = (Math.Round(decimal.Parse(BV.Text), 2).ToString());
            row[5] = (Math.Round(decimal.Parse(CGST.Text), 2).ToString());
            row[6] = (Math.Round(decimal.Parse(SGST.Text), 2).ToString());
            row[7] = (Math.Round(decimal.Parse(IGST.Text), 2).ToString());
            row[8] = (Math.Round(decimal.Parse(Cess.Text), 2).ToString());
            row[9] = (Math.Round(decimal.Parse(Tax.Text), 2).ToString());

            row[10] = Qty.Text;
            row[11] = (Math.Round(decimal.Parse(DP.Text) * decimal.Parse(Qty.Text), 2).ToString());
            row[12] = (Math.Round(decimal.Parse(CashBack.Text), 2).ToString());
            row[13] = (Math.Round(decimal.Parse(SPDiscount.Text), 2).ToString());

            dt.Rows.Add(row);
            ProductName.Text     = "";
            ProductCode.Text     = "";
            MRP.Text             = "";
            DP.Text              = "";
            BV.Text              = "";
            Qty.Text             = "";
            Tax.Text             = "";
            Amount.Text          = "";
            PID.Value            = "";
            CGST.Text            = "";
            SGST.Text            = "";
            Cess.Text            = "";
            GridView1.DataSource = dt;
            GridView1.DataBind();
            CalcTotals();
            // ProductCode.Focus();
            ProductName.Focus();
        }
Example #8
0
        /// <summary>
        /// 按钮事件:提交信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string fileSize = reName.Text;

            Regex reg  = new Regex("^(-?[0-9]+)(.[0-9]{1,10})?$", RegexOptions.IgnoreCase);
            var   size = fileSize.ToUpper().Remove(fileSize.Length - 2);


            if (!(fileSize.ToUpper().EndsWith("KB") ||
                  fileSize.ToUpper().EndsWith("MB") ||
                  fileSize.ToUpper().EndsWith("GB")) ||
                !reg.IsMatch(size))
            {
                reName.Focus();
                JavaScriptHelper.Error(this, "文件大小的格式应为:KB/MB/GB");
                return;
            }

            //验证重复
            if (id <= 0 && DB.getDataTable("select * from Product where ProductName='" + ProductName.Text.Trim() + "'").Rows.Count > 0)
            {
                ProductName.Focus();
                JavaScriptHelper.Error(this, "已存在");
                return;
            }

            StringBuilder strSql = new StringBuilder();
            string        simg   = string.Empty;

            if (id <= 0)//添加
            {
                simg = Common.UploadFile(FileUpload1, this.Page, "false");
                if (simg == "false")
                {
                    return;
                }

                strSql.Append("insert into Product(");
                strSql.Append("ProductName,FenLeiId,FenLeiName,Content,AddTime,Hits,reName,FileType,sImg,State,UserId,UserName,zanNum,IsTJ");
                strSql.Append(") values (");
                strSql.Append("'" + ProductName.Text + "','" + FenLei.SelectedValue + "','" + FenLei.SelectedItem.Text + "','" + Common.ConvertHtmlToString(Content.Text) + "',getdate(),0");
                strSql.Append(",'" + reName.Text + "','" + FileType.SelectedValue + "','" + simg + "','" + State.SelectedValue + "','" + mbId + "','" + mbTrueName + "',0,'" + IsTJ.SelectedValue + "') ");
            }
            else//修改
            {
                if (FileUpload1.HasFile)
                {
                    simg = Common.UploadFile(FileUpload1, this.Page, "false");
                }
                else
                {
                    simg = ltlPath.Text;
                }

                strSql.Append("update Product set ");

                strSql.Append(" ProductName = '" + ProductName.Text.Trim() + "'");
                strSql.Append(" ,FenLeiId = '" + FenLei.SelectedValue + "'");
                strSql.Append(" ,FenLeiName = '" + FenLei.SelectedItem.Text + "'");
                strSql.Append(" ,Content = '" + Common.ConvertHtmlToString(Content.Text) + "'");
                strSql.Append(" ,reName = '" + reName.Text + "'");
                strSql.Append(" ,FileType = '" + FileType.SelectedValue + "'");
                strSql.Append(" ,simg = '" + simg + "'");
                strSql.Append(" ,State = '" + State.SelectedValue + "'");
                strSql.Append(" ,IsTJ = '" + IsTJ.SelectedValue + "'");

                strSql.Append(" where Id= " + id);
            }
            DB.ExecuteSql(strSql.ToString());

            JavaScriptHelper.Success(this, "保存成功", "ProductManage.aspx");
        }