Esempio n. 1
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            bool hasError = false;
            foreach (DataGridViewRow row in dataGridViewItems.Rows)
            {
                var item = new ItemBO();

                item.ItemID = int.Parse(row.Cells[0].Value.ToString());
                item.QtyInHand = decimal.Parse(row.Cells[4].Value.ToString());

                var result =new ItemDAL().UpdateQuantityInHand(item);

                if (!result)
                {
                    MessageBoxClass.ShowMessage(CommonMethods.GetError("INV_021"), false);
                    hasError = true;
                    return;
                }

            }
            if (!hasError)
            {
                MessageBoxClass.ShowMessage(CommonMethods.GetError("INV_022"), false);
            }
        }
Esempio n. 2
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (ItemID > 0 && !ScreenFunctions.Update)
                {
                    MessageBoxClass.ShowMessage(CommonMethods.GetError("INV_020"), false);
                    return;
                }

                DialogResult dialogResult = MessageBoxClass.ShowDialog(CommonMethods.GetError("INV_018"));
                if (dialogResult == DialogResult.Yes)
                {
                    if (CommonMethods.IsEmpty(textBoxItemDescription.Text))
                    {
                        MessageBoxClass.ShowMessage(CommonMethods.GetError("INV_001"), false);
                        return;
                    }
                    if (CommonMethods.IsEmpty(textBoxItemNo.Text))
                    {
                        MessageBoxClass.ShowMessage(CommonMethods.GetError("INV_002"), false);
                        return;
                    }
                    if (CommonMethods.IsEmpty(textBoxMeasuringUnit.Text))
                    {
                        MessageBoxClass.ShowMessage(CommonMethods.GetError("INV_003"), false);
                        return;
                    }

                    var item = new ItemBO();
                    if (ItemID > 0)
                        item.ItemID = ItemID;
                    else
                        item.ItemID = -1;
                    item.ItemSerial = textBoxItemNo.Text.Trim();
                    item.MeasuringUnit = MeasuringUnit;
                    item.QtyInHand = numericUpDownQtyInHand.Value;
                    item.UnitPrice = numericUpDownUnitPrice.Value;
                    item.BreakEven = numericUpDownBreakEvenPoint.Value;
                    item.CreatedUser = 0;
                    item.Description = textBoxItemDescription.Text.Trim();

                    var objItemDAL = new ItemDAL();

                    bool result = objItemDAL.AddItem(item);
                    if (result)
                    {
                        MessageBoxClass.ShowMessage(CommonMethods.GetError("INV_004"), false);
                        button1_Click(null, null);
                    }
                    else
                    {
                        MessageBoxClass.ShowMessage(CommonMethods.GetError("INV_005"), false);
                    }
                }
            }
            catch
            {
                MessageBoxClass.ShowMessage(CommonMethods.GetError("U_007"), true);
            }
        }
Esempio n. 3
0
        public bool UpdateQuantityInHand(ItemBO item)
        {
            DBEgine objDbAccess = new DBEgine();
            bool result = false;
            try
            {
                SqlParameter[] parms = new SqlParameter[2];

                SqlParameter parmItemID = new SqlParameter();
                parmItemID.Value = item.ItemID;
                parmItemID.SqlDbType = SqlDbType.Int;
                parmItemID.Direction = ParameterDirection.Input;
                parmItemID.ParameterName = "@ItemID";
                parms[0] = parmItemID;

                SqlParameter parmBreakEven = new SqlParameter();
                parmBreakEven.Value = item.QtyInHand;
                parmBreakEven.SqlDbType = SqlDbType.Decimal;
                parmBreakEven.Direction = ParameterDirection.Input;
                parmBreakEven.ParameterName = "@QtyInHand";
                parms[1] = parmBreakEven;

                objDbAccess.DBOpen();

                if (objDbAccess.ExecNonQueryStoredProc("Inventory.UpdateQtyInhandByItemId", parms) > 0)
                {
                    result = true;
                }
                return result;

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objDbAccess.DBClose();
            }
        }
Esempio n. 4
0
        public ItemBO GetItemByItemNo(string itemNo)
        {
            DBEgine objDbAccess = new DBEgine();
            var item = new ItemBO();
            try
            {

                SqlParameter[] parms = new SqlParameter[1];

                SqlParameter parmItemID = new SqlParameter();
                parmItemID.Value = itemNo;
                parmItemID.SqlDbType = SqlDbType.VarChar;
                parmItemID.Direction = ParameterDirection.Input;
                parmItemID.ParameterName = "@ItemSerial";
                parms[0] = parmItemID;

                objDbAccess.DBOpen();

                SqlDataReader dr = objDbAccess.ExecuteReader("Inventory.GetItemByItemNo", parms);

                while (dr.Read())
                {
                    item.ItemID = int.Parse(dr["ItemID"].ToString());
                    item.ItemSerial = dr["ItemSerial"].ToString();
                    item.Description = dr["ItemDescription"].ToString();
                    item.UnitPrice = Convert.ToDecimal(dr["UnitPrice"].ToString());
                    item.MeasuringUnit = Convert.ToInt16(dr["MeasureUnit"].ToString());
                    item.QtyInHand = Convert.ToDecimal(dr["QtyInHand"].ToString());
                    item.BreakEven = Convert.ToDecimal(dr["BreakEven"].ToString());

                }

                return item;

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objDbAccess.DBClose();
            }
        }
Esempio n. 5
0
        public bool AddItem(ItemBO item)
        {
            DBEgine objDbAccess = new DBEgine();
            bool result = false;
            try
            {
                SqlParameter[] parms = new SqlParameter[8];

                SqlParameter parmItemID = new SqlParameter();
                parmItemID.Value = item.ItemID;
                parmItemID.SqlDbType = SqlDbType.Int;
                parmItemID.Direction = ParameterDirection.Input;
                parmItemID.ParameterName = "@ItemID";
                parms[0] = parmItemID;

                SqlParameter parmItemSerial = new SqlParameter();
                parmItemSerial.Value = item.ItemSerial;
                parmItemSerial.SqlDbType = SqlDbType.NVarChar;
                parmItemSerial.Direction = ParameterDirection.Input;
                parmItemSerial.ParameterName = "@ItemSerial";
                parms[1] = parmItemSerial;

                SqlParameter parmDescription = new SqlParameter();
                parmDescription.Value = item.Description;
                parmDescription.SqlDbType = SqlDbType.NVarChar;
                parmDescription.Direction = ParameterDirection.Input;
                parmDescription.ParameterName = "@Description";
                parms[2] = parmDescription;

                SqlParameter parmMeasuringUnit = new SqlParameter();
                parmMeasuringUnit.Value = item.MeasuringUnit;
                parmMeasuringUnit.SqlDbType = SqlDbType.Int;
                parmMeasuringUnit.Direction = ParameterDirection.Input;
                parmMeasuringUnit.ParameterName = "@MeasuringUnit";
                parms[3] = parmMeasuringUnit;

                SqlParameter parmCreatedUser = new SqlParameter();
                parmCreatedUser.Value = item.CreatedUser;
                parmCreatedUser.SqlDbType = SqlDbType.Int;
                parmCreatedUser.Direction = ParameterDirection.Input;
                parmCreatedUser.ParameterName = "@CreatedUser";
                parms[4] = parmCreatedUser;

                SqlParameter parmQtyInHand = new SqlParameter();
                parmQtyInHand.Value = item.QtyInHand;
                parmQtyInHand.SqlDbType = SqlDbType.Decimal;
                parmQtyInHand.Direction = ParameterDirection.Input;
                parmQtyInHand.ParameterName = "@QtyInHand";
                parms[5] = parmQtyInHand;

                SqlParameter parmUnitPrice = new SqlParameter();
                parmUnitPrice.Value = item.UnitPrice;
                parmUnitPrice.SqlDbType = SqlDbType.Decimal;
                parmUnitPrice.Direction = ParameterDirection.Input;
                parmUnitPrice.ParameterName = "@UnitPrice";
                parms[6] = parmUnitPrice;

                SqlParameter parmBreakEven = new SqlParameter();
                parmBreakEven.Value = item.BreakEven;
                parmBreakEven.SqlDbType = SqlDbType.Decimal;
                parmBreakEven.Direction = ParameterDirection.Input;
                parmBreakEven.ParameterName = "@BreakEven";
                parms[7] = parmBreakEven;

                objDbAccess.DBOpen();

                if (objDbAccess.ExecNonQueryStoredProc("Inventory.AddItems", parms) > 0)
                {
                    result = true;
                }

                return result;

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objDbAccess.DBClose();
            }
        }
Esempio n. 6
0
        public List<ItemBO> CheckInventory()
        {
            DBEgine objDbAccess = new DBEgine();
            var list= new List<ItemBO>();
            try
            {
                objDbAccess.DBOpen();

                SqlDataReader dr = objDbAccess.ExecuteReader("Inventory.CheckInventory", null);

                while (dr.Read())
                {
                    var item = new ItemBO();
                    item.ItemID = int.Parse(dr["ItemID"].ToString());
                    item.ItemSerial = dr["ItemSerial"].ToString();
                    item.Description = dr["ItemDescription"].ToString();
                    item.UnitPrice = Convert.ToDecimal(dr["UnitPrice"].ToString());
                    item.MeasuringUnit = Convert.ToInt16(dr["MeasureUnit"].ToString());
                    item.QtyInHand = Convert.ToDecimal(dr["QtyInHand"].ToString());
                    item.BreakEven = Convert.ToDecimal(dr["BreakEven"].ToString());

                    list.Add(item);

                }

                return list;

            }
            catch
            {
                throw;
            }
            finally
            {
                objDbAccess.DBClose();
            }
        }