Example #1
0
        //---------Insert CostPrice Details--------
        public string CostPrice_Insert(CPMaster costPrice)
        {
            string result = "";

            try
            {
                cmd.Parameters.Add("@CP_CODE", SqlDbType.VarChar, 1).Value = costPrice.CP_CODE;
                cmd.Parameters.Add("@RATE", SqlDbType.VarChar, 1).Value    = costPrice.RATE;
                cmd.Parameters.AddWithValue("@Action ", "INST");
                conn.Open();
                result = cmd.ExecuteNonQuery().ToString();
                return(result);
            }
            catch (SqlException sqlException)
            {
                if (sqlException.Number == 2601 || sqlException.Number == 2627)
                {
                    result = "Either Code or Value is duplicate.";
                }

                return(result);
            }
            finally
            {
                conn.Close();
            }
        }
Example #2
0
        //---------Update CostPrice Details--------
        public string CostPrice_Update(CPMaster costPrice)
        {
            string result = "";

            try
            {
                conn.Open();
                cmd.Parameters.Add("@RATE", SqlDbType.VarChar, 1).Value = costPrice.RATE;
                cmd.Parameters.AddWithValue("@Pid", costPrice.PID);
                cmd.Parameters.AddWithValue("@Action", "UPDT");

                int res = cmd.ExecuteNonQuery();
                return(result);
            }
            catch (SqlException sqlException)
            {
                if (sqlException.Number == 2601 || sqlException.Number == 2627)
                {
                    result = "Value is duplicate.";
                }
                return(result);
            }
            finally
            {
                conn.Close();
            }
        }
Example #3
0
        //---------Get CostPrice Details--------
        public CPMaster CostPrice_GetById(int?pid)
        {
            DataTable dt        = null;
            CPMaster  costPrice = null;

            try
            {
                cmd.Parameters.AddWithValue("@Pid", pid);
                cmd.Parameters.AddWithValue("@Action", "SHOW");
                conn.Open();
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                dt = new DataTable();
                da.Fill(dt);
                costPrice = GetList.DataTableToList <CPMaster>(dt).FirstOrDefault();

                return(costPrice);
            }
            catch
            {
                return(costPrice);
            }
            finally
            {
                conn.Close();
            }
        }
Example #4
0
        public HttpResponseMessage PutCostPrice(CPMaster costPrice)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var result = new CostPrice().CostPrice_Update(costPrice);

                    if (result != null || result != "")
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, result));
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.NoContent));
            }
            catch
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }