예제 #1
0
        public IHttpActionResult PostRawMaterialDisbursement([FromBody] RawDisbursement rd)
        {
            var result       = (Object)null;
            var ReturnedData = (Object)null;

            if (rd.BusinessId > 0 && rd.UserId > 0 && rd.ProductManagerId > 0)
            {
                if (cuc.ConfirmRawMaterialIDAgainstBusinessID(rd.BusinessId, rd.ProductManagerId, 2) == 1)
                {
                    rv     = st.AddModifyRawMaterialDistribution(rd);
                    result = cuc.GetJsonObject(ReturnedData, rv);
                }
                else
                {
                    rv.StatusCode = 7; rv.StatusMessage = "This product manager does not exist in your business";
                    result        = cuc.GetJsonObject(ReturnedData, rv);
                }
            }
            else
            {
                rv.StatusCode = 6; rv.StatusMessage = "you did not supply businessid or userid or productManagerId";
                result        = cuc.GetJsonObject(ReturnedData, rv);
            }
            return(Ok(result));
        }
예제 #2
0
        public List <RawDisbursement> getRawMaterialDistributionTicket(int businessid)
        {
            List <RawDisbursement> rd = new List <RawDisbursement>();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("getRawMaterialDistributionTicket", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@businessid", businessid);
                    try
                    {
                        RawDisbursement _sm    = new RawDisbursement();
                        SqlDataReader   reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                _sm = new RawDisbursement
                                {
                                    DistributId              = Convert.ToInt32(reader["DistributId"]),
                                    BusinessId               = Convert.ToInt32(reader["BusinessId"]),
                                    UserId                   = Convert.ToInt32(reader["UserId"]),
                                    CreatedBy                = reader["createdUser"] is DBNull ? null : (String)reader["createdUser"],
                                    createddate              = Convert.ToDateTime(reader["createddate"]),
                                    ProductManagerId         = Convert.ToInt32(reader["ProductManagerId"]),
                                    productManagerName       = reader["productmanager"] is DBNull ? null : (String)reader["productmanager"],
                                    productmanagerAccept     = Convert.ToInt32(reader["productManagerAccept"]),
                                    productManagerAcceptDate = reader["productManagerAcceptDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(reader["productManagerAcceptDate"]),
                                    AdminApprove             = Convert.ToInt32(reader["AdminApprove"]),
                                    AdminName                = reader["AdminApproveName"] is DBNull ? null : (String)reader["AdminApproveName"],
                                    AdminApproveDate         = reader["AdminApproveDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(reader["AdminApproveDate"]),
                                    Items = getRawMaterialDistributionTicketItems(Convert.ToInt32(reader["DistributId"])),
                                };

                                rd.Add(_sm);
                            }
                        }
                        else
                        {
                            rd = null;
                        }
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                    }
                }
            }

            return(rd);
        }
예제 #3
0
        public ReturnValues AddModifyRawMaterialDistribution(RawDisbursement rd)
        {
            ReturnValues rv = new ReturnValues();

            using (SqlConnection conn = connect.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("CreateModifyRawMaterialDistribution", conn))//call Stored Procedure
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@DistributId", rd.DistributId);
                    cmd.Parameters.AddWithValue("@userid", rd.UserId);
                    cmd.Parameters.AddWithValue("@businessid", rd.BusinessId);
                    cmd.Parameters.AddWithValue("@ProductManagerId", rd.ProductManagerId);
                    cmd.Parameters.Add("@returnvalue", SqlDbType.Int);
                    cmd.Parameters["@returnvalue"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@returnvalueString", System.Data.SqlDbType.VarChar, 200);
                    cmd.Parameters["@returnvalueString"].Direction = ParameterDirection.Output;
                    try
                    {
                        cmd.ExecuteNonQuery();


                        rv.StatusCode = Convert.ToInt32(cmd.Parameters["@returnvalue"].Value);
                        this.AddModifyRawMaterialDistribution(rv.StatusCode, rd.Items);
                        rv.StatusMessage = Convert.ToString(cmd.Parameters["@returnvalueString"].Value);
                        rv.StatusCode    = 1;
                    }
                    catch (Exception ex)
                    {
                        CommonUtilityClass.ExceptionLog(ex);
                        rv.StatusCode    = 2000;
                        rv.StatusMessage = "An Error Occured";
                    }
                }
            }
            return(rv);
        }