public bool CheckOtherChargeCodeExist(OtherCharge otherCharge)
        {
            try
            {
                using (SqlConnection con = _databaseFactory.GetDBConnection())
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        if (con.State == ConnectionState.Closed)
                        {
                            con.Open();
                        }
                        cmd.Connection  = con;
                        cmd.CommandText = "[PSA].[CheckOtherChargeCodeExist]";
                        cmd.Parameters.Add("@Code", SqlDbType.Int).Value = otherCharge.Code;
                        cmd.Parameters.Add("@Description", SqlDbType.VarChar, 250).Value = otherCharge.Description;
                        cmd.CommandType = CommandType.StoredProcedure;
                        Object res = cmd.ExecuteScalar();
                        return(res.ToString() == "Exists" ? true : false);
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
        public List <OtherCharge> GetAllOtherCharge(OtherChargeAdvanceSearch otherChargeAdvanceSearch)
        {
            List <OtherCharge> otherChargeList = null;

            try
            {
                using (SqlConnection con = _databaseFactory.GetDBConnection())
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        if (con.State == ConnectionState.Closed)
                        {
                            con.Open();
                        }
                        cmd.Connection  = con;
                        cmd.CommandText = "[PSA].[GetAllOtherCharge]";
                        cmd.Parameters.Add("@SearchValue", SqlDbType.NVarChar, -1).Value = string.IsNullOrEmpty(otherChargeAdvanceSearch.SearchTerm) ? "" : otherChargeAdvanceSearch.SearchTerm.Trim();
                        cmd.Parameters.Add("@RowStart", SqlDbType.Int).Value             = otherChargeAdvanceSearch.DataTablePaging.Start;
                        if (otherChargeAdvanceSearch.DataTablePaging.Length == -1)
                        {
                            cmd.Parameters.AddWithValue("@Length", DBNull.Value);
                        }
                        else
                        {
                            cmd.Parameters.Add("@Length", SqlDbType.Int).Value = otherChargeAdvanceSearch.DataTablePaging.Length;
                        }
                        cmd.CommandType = CommandType.StoredProcedure;
                        using (SqlDataReader sdr = cmd.ExecuteReader())
                        {
                            if ((sdr != null) && (sdr.HasRows))
                            {
                                otherChargeList = new List <OtherCharge>();
                                while (sdr.Read())
                                {
                                    OtherCharge otherCharge = new OtherCharge();
                                    {
                                        otherCharge.Code          = (sdr["Code"].ToString() != "" ? int.Parse(sdr["Code"].ToString()) : otherCharge.Code);
                                        otherCharge.Description   = (sdr["Description"].ToString() != "" ? sdr["Description"].ToString() : otherCharge.Description);
                                        otherCharge.SACCode       = (sdr["SACCode"].ToString() != "" ? sdr["SACCode"].ToString() : otherCharge.SACCode);
                                        otherCharge.TotalCount    = (sdr["TotalCount"].ToString() != "" ? int.Parse(sdr["TotalCount"].ToString()) : otherCharge.TotalCount);
                                        otherCharge.FilteredCount = (sdr["FilteredCount"].ToString() != "" ? int.Parse(sdr["FilteredCount"].ToString()) : otherCharge.FilteredCount);
                                    }
                                    otherChargeList.Add(otherCharge);
                                }
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }

            return(otherChargeList);
        }
Exemple #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            OtherCharge item = db.OtherCharges.Find(id);

            db.OtherCharges.Remove(item);
            db.SaveChanges();
            TempData["SuccessMSG"] = "You have successfully deleted Other Charge.";
            return(RedirectToAction("Index"));
        }
Exemple #4
0
        public ActionResult Edit(int id = 0)
        {
            ViewBag.accounthead = db.AcHeads.OrderBy(x => x.AcHead1).ToList();
            OtherCharge otherCharge = db.OtherCharges.Find(id);

            if (otherCharge == null)
            {
                return(HttpNotFound());
            }

            return(View(otherCharge));
        }
        public List <OtherCharge> GetOtherChargeForSelectList()
        {
            List <OtherCharge> otherChargeList = null;

            try
            {
                using (SqlConnection con = _databaseFactory.GetDBConnection())
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        if (con.State == ConnectionState.Closed)
                        {
                            con.Open();
                        }
                        cmd.Connection  = con;
                        cmd.CommandText = "[PSA].[GetOtherChargeForSelectList]";
                        cmd.CommandType = CommandType.StoredProcedure;
                        using (SqlDataReader sdr = cmd.ExecuteReader())
                        {
                            if ((sdr != null) && (sdr.HasRows))
                            {
                                otherChargeList = new List <OtherCharge>();
                                while (sdr.Read())
                                {
                                    OtherCharge otherCharge = new OtherCharge();
                                    {
                                        otherCharge.Code        = (sdr["Code"].ToString() != "" ? int.Parse(sdr["Code"].ToString()) : otherCharge.Code);
                                        otherCharge.Description = (sdr["Description"].ToString() != "" ? sdr["Description"].ToString() : otherCharge.Description);
                                    }
                                    otherChargeList.Add(otherCharge);
                                }
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }

            return(otherChargeList);
        }
Exemple #6
0
        public ActionResult Edit(OtherCharge vm)
        {
            if (ModelState.IsValid)
            {
                OtherCharge data = db.OtherCharges.Find(vm.OtherChargeID);
                data.OtherCharge1    = vm.OtherCharge1;
                data.SetAmount       = vm.SetAmount;
                data.TypePercent     = vm.TypePercent;
                data.Reimbursement   = vm.Reimbursement;
                data.TaxApplicable   = vm.TaxApplicable;
                data.AcHeadID        = vm.AcHeadID;
                db.Entry(data).State = EntityState.Modified;
                db.SaveChanges();

                TempData["SuccessMSG"] = "You have successfully updated Other Charge.";
                return(RedirectToAction("Index"));
            }

            return(View(vm));
        }
        public OtherCharge GetOtherCharge(int code)
        {
            OtherCharge otherCharge = null;

            try
            {
                using (SqlConnection con = _databaseFactory.GetDBConnection())
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        if (con.State == ConnectionState.Closed)
                        {
                            con.Open();
                        }
                        cmd.Connection  = con;
                        cmd.CommandText = "[PSA].[GetOtherCharge]";
                        cmd.Parameters.Add("@Code", SqlDbType.VarChar).Value = code;
                        cmd.CommandType = CommandType.StoredProcedure;
                        using (SqlDataReader sdr = cmd.ExecuteReader())
                        {
                            if ((sdr != null) && (sdr.HasRows))
                            {
                                if (sdr.Read())
                                {
                                    otherCharge             = new OtherCharge();
                                    otherCharge.Code        = (sdr["Code"].ToString() != "" ? int.Parse(sdr["Code"].ToString()) : otherCharge.Code);
                                    otherCharge.Description = (sdr["Description"].ToString() != "" ? sdr["Description"].ToString() : otherCharge.Description);
                                    otherCharge.SACCode     = (sdr["SACCode"].ToString() != "" ? sdr["SACCode"].ToString() : otherCharge.SACCode);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(otherCharge);
        }
Exemple #8
0
        public ActionResult Create(OtherChargeVM vm)
        {
            if (ModelState.IsValid)
            {
                int companyId = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
                var query     = (from t in db.OtherCharges where t.OtherCharge1 == vm.OtherCharge1 select t).ToList();

                if (query.Count > 0)
                {
                    ViewBag.accounthead = db.AcHeads.ToList();
                    ViewBag.SuccessMsg  = "OtherCharge name is already exist!";
                    return(View());
                }
                else
                {
                    OtherCharge data = new OtherCharge();
                    int         max1 = (from c1 in db.OtherCharges orderby c1.OtherChargeID descending select c1.OtherChargeID).FirstOrDefault();
                    data.OtherChargeID = max1 + 1;
                    data.OtherCharge1  = vm.OtherCharge1;
                    data.SetAmount     = vm.SetAmount;
                    data.TypePercent   = vm.TypePercent;
                    data.Reimbursement = vm.Reimbursement;
                    data.TaxApplicable = vm.TaxApplicable;
                    data.AcHeadID      = vm.AcHeadID;
                    data.AcCompanyID   = companyId;
                    db.OtherCharges.Add(data);
                    db.SaveChanges();
                }


                TempData["SuccessMSG"] = "You have successfully added Other Charge.";
                return(RedirectToAction("Index"));
            }

            return(View(vm));
        }
Exemple #9
0
 public bool CheckOtherChargeCodeExist(OtherCharge otherCharge)
 {
     return(_otherChargeRepository.CheckOtherChargeCodeExist(otherCharge));
 }
Exemple #10
0
 public object InsertUpdateOtherCharge(OtherCharge otherCharge)
 {
     return(_otherChargeRepository.InsertUpdateOtherCharge(otherCharge));
 }
        public object InsertUpdateOtherCharge(OtherCharge otherCharge)
        {
            SqlParameter outputStatus, outputCode = null;

            try
            {
                using (SqlConnection con = _databaseFactory.GetDBConnection())
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        if (con.State == ConnectionState.Closed)
                        {
                            con.Open();
                        }
                        cmd.Connection  = con;
                        cmd.CommandText = "[PSA].[InsertUpdateOtherCharge]";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@IsUpdate", SqlDbType.Bit).Value = otherCharge.IsUpdate;
                        if (otherCharge.Code == 0)
                        {
                            cmd.Parameters.AddWithValue("@Code", DBNull.Value);
                        }

                        else
                        {
                            cmd.Parameters.Add("@Code", SqlDbType.Int).Value = otherCharge.Code;
                        }
                        cmd.Parameters.Add("@Description", SqlDbType.VarChar, 250).Value = otherCharge.Description;
                        cmd.Parameters.Add("@SACCode", SqlDbType.VarChar, 30).Value      = otherCharge.SACCode;
                        cmd.Parameters.Add("@CreatedBy", SqlDbType.VarChar, 250).Value   = otherCharge.PSASysCommon.CreatedBy;
                        cmd.Parameters.Add("@CreatedDate", SqlDbType.DateTime).Value     = otherCharge.PSASysCommon.CreatedDate;
                        cmd.Parameters.Add("@UpdatedBy", SqlDbType.VarChar, 250).Value   = otherCharge.PSASysCommon.UpdatedBy;
                        cmd.Parameters.Add("@UpdatedDate", SqlDbType.DateTime).Value     = otherCharge.PSASysCommon.UpdatedDate;
                        outputStatus           = cmd.Parameters.Add("@Status", SqlDbType.SmallInt);
                        outputStatus.Direction = ParameterDirection.Output;
                        outputCode             = cmd.Parameters.Add("@CodeOut", SqlDbType.Int);
                        outputCode.Direction   = ParameterDirection.Output;
                        cmd.ExecuteNonQuery();
                    }
                }
                switch (outputStatus.Value.ToString())
                {
                case "0":
                    throw new Exception(otherCharge.IsUpdate ? _appConst.UpdateFailure : _appConst.InsertFailure);

                case "1":
                    otherCharge.Code = int.Parse(outputCode.Value.ToString());
                    return(new
                    {
                        Code = outputCode.Value.ToString(),
                        Status = outputStatus.Value.ToString(),
                        Message = otherCharge.IsUpdate ? _appConst.UpdateSuccess : _appConst.InsertSuccess
                    });
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(new
            {
                Code = outputCode.Value.ToString(),
                Status = outputStatus.Value.ToString(),
                Message = otherCharge.IsUpdate ? _appConst.UpdateSuccess : _appConst.InsertSuccess
            });
        }