public List<SubItemDetailBO> GetSubItemDetailBySubItemID(int id)
        {
            DBEgine objDbAccess = new DBEgine();
            var list = new List<SubItemDetailBO>();
            try
            {
                SqlParameter[] parms = new SqlParameter[1];

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

                objDbAccess.DBOpen();

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

                while (dr.Read())
                {
                    var subItemDetail = new SubItemDetailBO();

                    subItemDetail.SubItemID = int.Parse(dr["SubItemID"].ToString());
                    subItemDetail.Serial = dr["ItemSerial"].ToString();
                    subItemDetail.UnitOfMeasureID = int.Parse(dr["UnitOfMeasureID"].ToString());
                    subItemDetail.SubItemDetailID = int.Parse(dr["SubItemDetailID"].ToString());
                    subItemDetail.ItemID = int.Parse(dr["ItemID"].ToString());
                    subItemDetail.QtyForUnit = decimal.Parse(dr["QtyForUnit"].ToString());
                    subItemDetail.Description = dr["ItemDescription"].ToString();
                    subItemDetail.UnitOfMeasureName = dr["UnitDescription"].ToString();

                    list.Add(subItemDetail);

                }
                return list;

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objDbAccess.DBClose();
            }
        }
        public bool SaveSubItemWithTransaction(SubItemDetailBO subItemDetail, DBEgine objDbAccess)
        {
            bool result = false;
            try
            {
                SqlParameter[] parms = new SqlParameter[4];

                SqlParameter parmSubItemID = new SqlParameter();
                parmSubItemID.Value = subItemDetail.SubItemID;
                parmSubItemID.SqlDbType = SqlDbType.Int;
                parmSubItemID.Direction = ParameterDirection.Input;
                parmSubItemID.ParameterName = "@SubItemID";
                parms[0] = parmSubItemID;

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

                SqlParameter parmQtyForUnit = new SqlParameter();
                parmQtyForUnit.Value = subItemDetail.QtyForUnit;
                parmQtyForUnit.SqlDbType = SqlDbType.Decimal;
                parmQtyForUnit.Direction = ParameterDirection.Input;
                parmQtyForUnit.ParameterName = "@QtyForUnit";
                parms[2] = parmQtyForUnit;

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

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

                return result;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #3
0
        private void buttonAddSubItem_Click(object sender, EventArgs e)
        {
            try
            {
                var subItemDetailBO = new SubItemDetailBO();

                subItemDetailBO.ItemID = ItemID;
                subItemDetailBO.SubItemID = SubItemID;
                subItemDetailBO.SubItemDetailID = -1;
                subItemDetailBO.UnitOfMeasureID = ItemMeasuringUnit;
                subItemDetailBO.UnitOfMeasureName = textBoxItemMesuringUnit.Text;
                subItemDetailBO.QtyForUnit = numericUpDownQtyAllocated.Value;
                subItemDetailBO.Description = textBoxItemDescription.Text;
                subItemDetailBO.Serial = textBoxItemNo.Text;

                var list=new List<SubItemDetailBO>();

                if(SubItemDetailBOList!=null)
                    list = SubItemDetailBOList.FindAll(s => s.ItemID == ItemID);

                if (list.Count() > 0)
                {
                    MessageBoxClass.ShowMessage(CommonMethods.GetError("INV_009"), false);
                }
                else
                {
                    SubItemDetailBOList.Add(subItemDetailBO);
                    BindDataToGridView();
                    ClearItem();
                }

            }
            catch
            {
                MessageBoxClass.ShowMessage(CommonMethods.GetError("U_007"), true);
            }
        }