Exemplo n.º 1
0
        public static bool Delete(InvoiceAdvance InvoiceAdvance)
        {
            SqlConnection connection      = PMMSData.GetConnection();
            string        deleteProcedure = "[InvoiceAdvanceDelete]";
            SqlCommand    deleteCommand   = new SqlCommand(deleteProcedure, connection);

            deleteCommand.CommandType = CommandType.StoredProcedure;
            deleteCommand.Parameters.AddWithValue("@OldInvoiceID", InvoiceAdvance.InvoiceID);
            deleteCommand.Parameters.AddWithValue("@OldAdvancePaymentID", InvoiceAdvance.AdvancePaymentID);
            deleteCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
            deleteCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
            try
            {
                connection.Open();
                deleteCommand.ExecuteNonQuery();
                int count = System.Convert.ToInt32(deleteCommand.Parameters["@ReturnValue"].Value);
                if (count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (SqlException)
            {
                return(false);
            }
            finally
            {
                connection.Close();
            }
        }
Exemplo n.º 2
0
        public ActionResult Edit(InvoiceAdvance InvoiceAdvance)
        {
            InvoiceAdvance oInvoiceAdvance = new InvoiceAdvance();

            oInvoiceAdvance.InvoiceID        = System.Convert.ToInt32(InvoiceAdvance.InvoiceID);
            oInvoiceAdvance.AdvancePaymentID = System.Convert.ToInt32(InvoiceAdvance.AdvancePaymentID);
            oInvoiceAdvance = InvoiceAdvanceData.Select_Record(InvoiceAdvance);

            if (ModelState.IsValid)
            {
                bool bSucess = false;
                bSucess = InvoiceAdvanceData.Update(oInvoiceAdvance, InvoiceAdvance);
                if (bSucess == true)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", "Can Not Update");
                }
            }
            // ComboBox
            ViewData["InvoiceID"]        = new SelectList(InvoiceAdvance_InvoiceData.List(), "InvoiceID", "InvoiceID", InvoiceAdvance.InvoiceID);
            ViewData["AdvancePaymentID"] = new SelectList(InvoiceAdvance_AdvancePaymentData.List(), "AdvancePaymentID", "AdvancePaymentID", InvoiceAdvance.AdvancePaymentID);

            return(View(InvoiceAdvance));
        }
Exemplo n.º 3
0
        // GET: /InvoiceAdvance/Edit/<id>
        public ActionResult Edit(
            Int32?InvoiceID
            , Int32?AdvancePaymentID
            )
        {
            if (
                InvoiceID == null ||
                AdvancePaymentID == null
                )
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            InvoiceAdvance InvoiceAdvance = new InvoiceAdvance();

            InvoiceAdvance.InvoiceID        = System.Convert.ToInt32(InvoiceID);
            InvoiceAdvance.AdvancePaymentID = System.Convert.ToInt32(AdvancePaymentID);
            InvoiceAdvance = InvoiceAdvanceData.Select_Record(InvoiceAdvance);

            if (InvoiceAdvance == null)
            {
                return(HttpNotFound());
            }
            // ComboBox
            ViewData["InvoiceID"]        = new SelectList(InvoiceAdvance_InvoiceData.List(), "InvoiceID", "InvoiceID", InvoiceAdvance.InvoiceID);
            ViewData["AdvancePaymentID"] = new SelectList(InvoiceAdvance_AdvancePaymentData.List(), "AdvancePaymentID", "AdvancePaymentID", InvoiceAdvance.AdvancePaymentID);

            return(View(InvoiceAdvance));
        }
Exemplo n.º 4
0
        public static InvoiceAdvance Select_Record(InvoiceAdvance InvoiceAdvancePara)
        {
            InvoiceAdvance InvoiceAdvance  = new InvoiceAdvance();
            SqlConnection  connection      = PMMSData.GetConnection();
            string         selectProcedure = "[InvoiceAdvanceSelect]";
            SqlCommand     selectCommand   = new SqlCommand(selectProcedure, connection);

            selectCommand.CommandType = CommandType.StoredProcedure;
            selectCommand.Parameters.AddWithValue("@InvoiceID", InvoiceAdvancePara.InvoiceID);
            selectCommand.Parameters.AddWithValue("@AdvancePaymentID", InvoiceAdvancePara.AdvancePaymentID);
            try
            {
                connection.Open();
                SqlDataReader reader
                    = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    InvoiceAdvance.InvoiceID        = System.Convert.ToInt32(reader["InvoiceID"]);
                    InvoiceAdvance.AdvancePaymentID = System.Convert.ToInt32(reader["AdvancePaymentID"]);
                }
                else
                {
                    InvoiceAdvance = null;
                }
                reader.Close();
            }
            catch (SqlException)
            {
                return(InvoiceAdvance);
            }
            finally
            {
                connection.Close();
            }
            return(InvoiceAdvance);
        }
Exemplo n.º 5
0
        public ActionResult DeleteConfirmed(
            Int32?InvoiceID
            , Int32?AdvancePaymentID
            )
        {
            InvoiceAdvance InvoiceAdvance = new InvoiceAdvance();

            InvoiceAdvance.InvoiceID        = System.Convert.ToInt32(InvoiceID);
            InvoiceAdvance.AdvancePaymentID = System.Convert.ToInt32(AdvancePaymentID);
            InvoiceAdvance = InvoiceAdvanceData.Select_Record(InvoiceAdvance);

            bool bSucess = false;

            bSucess = InvoiceAdvanceData.Delete(InvoiceAdvance);
            if (bSucess == true)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", "Can Not Delete");
            }
            return(null);
        }
Exemplo n.º 6
0
        // GET: /InvoiceAdvance/Delete/<id>
        public ActionResult Delete(
            Int32?InvoiceID
            , Int32?AdvancePaymentID
            )
        {
            if (
                InvoiceID == null ||
                AdvancePaymentID == null
                )
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            dtInvoice        = InvoiceAdvance_InvoiceData.SelectAll();
            dtAdvancePayment = InvoiceAdvance_AdvancePaymentData.SelectAll();

            InvoiceAdvance InvoiceAdvance = new InvoiceAdvance();

            InvoiceAdvance.InvoiceID        = System.Convert.ToInt32(InvoiceID);
            InvoiceAdvance.AdvancePaymentID = System.Convert.ToInt32(AdvancePaymentID);
            InvoiceAdvance         = InvoiceAdvanceData.Select_Record(InvoiceAdvance);
            InvoiceAdvance.Invoice = new Invoice()
            {
                InvoiceID = (Int32)InvoiceAdvance.InvoiceID
            };
            InvoiceAdvance.AdvancePayment = new AdvancePayment()
            {
                AdvancePaymentID = (Int32)InvoiceAdvance.AdvancePaymentID
            };

            if (InvoiceAdvance == null)
            {
                return(HttpNotFound());
            }
            return(View(InvoiceAdvance));
        }
Exemplo n.º 7
0
        public ActionResult Create([Bind(Include =
                                             "InvoiceID"
                                             + "," + "AdvancePaymentID"
                                         )] InvoiceAdvance InvoiceAdvance)
        {
            if (ModelState.IsValid)
            {
                bool bSucess = false;
                bSucess = InvoiceAdvanceData.Add(InvoiceAdvance);
                if (bSucess == true)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", "Can Not Insert");
                }
            }
            // ComboBox
            ViewData["InvoiceID"]        = new SelectList(InvoiceAdvance_InvoiceData.List(), "InvoiceID", "InvoiceID", InvoiceAdvance.InvoiceID);
            ViewData["AdvancePaymentID"] = new SelectList(InvoiceAdvance_AdvancePaymentData.List(), "AdvancePaymentID", "AdvancePaymentID", InvoiceAdvance.AdvancePaymentID);

            return(View(InvoiceAdvance));
        }