Esempio n. 1
0
        public void LoadPriceData(string productid)
        {
            dalProductSalePrice dal = new dalProductSalePrice();
            BindingCollection <modProductSalePrice> list = dal.GetProductSalePrice(productid, out Util.emsg);

            DBGridPrice.DataSource = list;
            if (list != null)
            {
                DBGridPrice.Columns["ProductId"].Visible  = false;
                DBGridPrice.Columns["UpdateUser"].Visible = false;
                DBGridPrice.Columns["UpdateTime"].Visible = false;

                DBGridPrice.ReadOnly = false;
                DBGridPrice.Columns["CustLevel"].Width = 80;
                DBGridPrice.Columns["Price"].Width     = 100;
                DBGridPrice.Columns["Price"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                DBGridPrice.Columns["CustLevel"].ReadOnly                   = true;
                DBGridPrice.Columns["Price"].ReadOnly                       = false;
                DBGridPrice.AlternatingRowsDefaultCellStyle.BackColor       = Color.Empty;
                DBGridPrice.Columns["CustLevel"].DefaultCellStyle.BackColor = frmOptions.ALTERNATING_BACKCOLOR;

                if (DBGridPrice.RowCount > 0)
                {
                    DBGridPrice.CurrentCell = DBGridPrice.Rows[0].Cells["Price"];
                }
            }
        }
Esempio n. 2
0
        private void toolSavePrice_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                DBGridPrice.EndEdit();

                dalProductSalePrice dal = new dalProductSalePrice();
                BindingCollection <modProductSalePrice> list = (BindingCollection <modProductSalePrice>)DBGridPrice.DataSource;
                bool ret = dal.Save(list, out Util.emsg);
                if (ret)
                {
                    MessageBox.Show("数据保存成功!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Esempio n. 3
0
        private void txtProduct_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(Keys.Enter) || e.KeyChar == Convert.ToChar(Keys.Space))
            {
                dalProductSalePrice dalprice            = new dalProductSalePrice();
                dalProductList      dal                 = new dalProductList();
                BindingCollection <modProductList> list = dal.GetIListByBarcode(txtProduct.Text.Trim(), out Util.emsg);
                if (list != null && list.Count > 0)
                {
                    if (list.Count == 1)
                    {
                        DataGridViewRow row = new DataGridViewRow();
                        row.CreateCells(DBGrid);

                        row.Height         = 40;
                        row.Cells[0].Value = list[0].ProductId;
                        row.Cells[1].Value = list[0].ProductName;
                        row.Cells[2].Value = list[0].Barcode;
                        row.Cells[3].Value = list[0].UnitNo;
                        row.Cells[4].Value = 1;
                        row.Cells[5].Value = dalprice.GetDefaultPrice(list[0].ProductId, out Util.emsg);
                        row.Cells[6].Value = decimal.Parse(row.Cells[5].Value.ToString());
                        row.Cells[8].Value = list[0].Specify;
                        DBGrid.Rows.Add(row);
                        row.Dispose();
                    }
                    else
                    {
                        frmViewList frm = new frmViewList();
                        frm.InitViewList("请选择商品:", list);
                        frm.Selection = true;
                        if (frm.ShowDialog() == DialogResult.OK)
                        {
                            var             modPdt = list.Where(c => c.ProductId == Util.retValue1).First();
                            DataGridViewRow row    = new DataGridViewRow();
                            row.CreateCells(DBGrid);

                            row.Height         = 40;
                            row.Cells[0].Value = modPdt.ProductId;
                            row.Cells[1].Value = modPdt.ProductName;
                            row.Cells[2].Value = modPdt.Barcode;
                            row.Cells[3].Value = modPdt.UnitNo;
                            row.Cells[4].Value = 1;
                            row.Cells[5].Value = dalprice.GetDefaultPrice(modPdt.ProductId, out Util.emsg);
                            row.Cells[6].Value = decimal.Parse(row.Cells[5].Value.ToString());
                            row.Cells[8].Value = modPdt.Specify;
                            DBGrid.Rows.Add(row);
                            row.Dispose();
                        }
                    }
                    SumData();
                }
                else
                {
                    modProductList mod = dal.GetItem(txtProduct.Text.Trim(), out Util.emsg);
                    if (mod != null)
                    {
                        DataGridViewRow row = new DataGridViewRow();
                        row.CreateCells(DBGrid);

                        row.Height         = 40;
                        row.Cells[0].Value = mod.ProductId;
                        row.Cells[1].Value = mod.ProductName;
                        row.Cells[2].Value = mod.Barcode;
                        row.Cells[3].Value = mod.UnitNo;
                        row.Cells[4].Value = 1;
                        row.Cells[5].Value = dalprice.GetDefaultPrice(mod.ProductId, out Util.emsg);
                        row.Cells[6].Value = decimal.Parse(row.Cells[5].Value.ToString());
                        row.Cells[8].Value = mod.Specify;
                        DBGrid.Rows.Add(row);
                        row.Dispose();

                        SumData();
                    }
                    else
                    {
                        MessageBox.Show("没有找到商品!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }

                if (DBGrid.RowCount > 0)
                {
                    DBGrid.CurrentCell = DBGrid.Rows[DBGrid.RowCount - 1].Cells[4];
                }
                txtProduct.Text = string.Empty;
                txtProduct.Focus();
            }
        }