Esempio n. 1
0
        private void DoReturn()
        {
            ReturnedInfo returnobj = new ReturnedInfo();
            returnobj.ItemId = ((ItemInfo)cboItems.SelectedItem).ItemId;
            returnobj.QuantityReturned = txtQty.Text.Trim();
            returnobj.ReturnDate = dtpReturn.Text;
            returnobj.ReturnedBy = txtRetBy.Text.Trim();
            returnobj.ReceivedBy = ((UserInfo)cboUsers.SelectedItem).UserId;
            returnobj.ReturnReason = txtReturnReason.Text.Trim();

            try
            {
                ReturnedMapper.GetInstance().InsertReturn(returnobj);

                ItemInfo item = ItemMapper.Getinstance().GetItem(returnobj.ItemId);
                item.Returned = (Convert.ToInt32(item.Returned) + Convert.ToInt32(returnobj.QuantityReturned)).ToString();
                item.CurrentStock = (Convert.ToInt32(item.CurrentStock) + Convert.ToInt32(returnobj.QuantityReturned)).ToString();

                ItemMapper.Getinstance().UpdateItem(item);
                MessageBox.Show("Transaction Successfully completed");
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        public IList<ReturnedInfo> GetAllReturns()
        {
            IList<ReturnedInfo> allreturns = new List<ReturnedInfo>();

            using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction,
                System.Data.CommandType.Text, SQL_SELECT_ALL, null))
            {
                while(rdr.Read())
                {
                    ReturnedInfo retrn = new ReturnedInfo(rdr.GetString(0),
                        rdr.GetValue(1).GetType().Equals(typeof(DBNull)) ? "" : rdr.GetString(1),
                        rdr.GetValue(2).GetType().Equals(typeof(DBNull)) ? "" : rdr.GetString(2),
                        rdr.GetValue(3).GetType().Equals(typeof(DBNull)) ? "" : rdr.GetString(3),
                        rdr.GetValue(4).GetType().Equals(typeof(DBNull)) ? "" : rdr.GetString(4),
                        rdr.GetValue(5).GetType().Equals(typeof(DBNull)) ? "" : rdr.GetString(5),
                        rdr.GetValue(6).GetType().Equals(typeof(DBNull)) ? "" : rdr.GetString(6));

                    allreturns.Add(retrn);
                }
            }
            return allreturns;
        }
Esempio n. 3
0
 public void InsertReturn(ReturnedInfo returnobj)
 {
     SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, System.Data.CommandType.Text,
         SQL_INSERT_RETURN, CreateParameters(returnobj));
 }
Esempio n. 4
0
        public ReturnedInfo GetReturn(string returnid)
        {
            ReturnedInfo retn = null;
            SqlParameter param_retnid = new SqlParameter(PARAM_RETURNID,returnid);

            using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction,
                System.Data.CommandType.Text, SQL_SELECT_RETURN, param_retnid))
            {
                while (rdr.Read())
                {
                    retn = new ReturnedInfo(rdr.GetString(0),
                        rdr.GetValue(1).GetType().Equals(typeof(DBNull)) ? "" : rdr.GetString(1),
                        rdr.GetValue(2).GetType().Equals(typeof(DBNull)) ? "" : rdr.GetString(2),
                        rdr.GetValue(3).GetType().Equals(typeof(DBNull)) ? "" : rdr.GetString(3),
                        rdr.GetValue(4).GetType().Equals(typeof(DBNull)) ? "" : rdr.GetString(4),
                        rdr.GetValue(5).GetType().Equals(typeof(DBNull)) ? "" : rdr.GetString(5),
                        rdr.GetValue(6).GetType().Equals(typeof(DBNull)) ? "" : rdr.GetString(6));
                }
            }
            return retn;
        }
Esempio n. 5
0
        private SqlParameter[] CreateParameters(ReturnedInfo returnobj)
        {
            SqlParameter param_returnid = new SqlParameter(PARAM_RETURNID,returnobj.ReturnId);
            SqlParameter param_itemid = new SqlParameter(PARAM_ITEMID,returnobj.ItemId);
            SqlParameter param_qtyreturned = new SqlParameter(PARAM_QTYRET,returnobj.QuantityReturned);
            SqlParameter param_returndate = new SqlParameter(PARAM_RETDATE,returnobj.ReturnDate);
            SqlParameter param_returnedby = new SqlParameter(PARAM_RETBY,returnobj.ReturnedBy);
            SqlParameter param_receivedby = new SqlParameter(PARAM_RECBY,returnobj.ReceivedBy);
            SqlParameter param_returnreason = new SqlParameter(PARAM_RETRZN,returnobj.ReturnReason);

            return new SqlParameter[] {param_returnid,param_itemid,param_qtyreturned,param_returndate,param_returnedby, param_receivedby,param_returnreason };
        }