示例#1
0
        public int Save(List <Accounts> adobj)
        {
            int        Row = 0;
            DBCon      con = new DBCon();
            SqlCommand cmd = null;

            try
            {
                string Quary = "";
                if (this.AID == 0)
                {
                    Quary = "Insert Into ACAccount Values (@Date,@DRAmount,@CRAmount,@Narration,@Balance,@GroupId,@OrgId);SELECT SCOPE_IDENTITY();";
                }
                else
                {
                    Quary = "Update ACAccount Set Date=@Date,DRAmount=@DRAmount,CRAmount=@CRAmount,Narration=@Narration,Balance=@Balance,GroupId=@GroupId,OrgId=@OrgId where AID=@AID";
                }
                cmd = new SqlCommand(Quary, con.Con);
                cmd.Parameters.AddWithValue("@AID", this.AID);
                cmd.Parameters.AddWithValue("@Date", this.Date);
                cmd.Parameters.AddWithValue("@DRAmount", this.DRAmount);
                cmd.Parameters.AddWithValue("@CRAmount", this.CRAmount);
                cmd.Parameters.AddWithValue("@Narration", this.Narration);
                cmd.Parameters.AddWithValue("@Balance", this.Balance);
                cmd.Parameters.AddWithValue("@CRGroupId", this.CRGroupId);
                cmd.Parameters.AddWithValue("@OrgId", this.AOrgId);
                cmd.Parameters.AddWithValue("@DRGroupId", this.DRGroupId);
                cmd.Parameters.AddWithValue("@CRLedgerId", this.ACRLedgerId);
                cmd.Parameters.AddWithValue("@DRLedgerId", this.ADRLedgerId);


                if (this.AID == 0)
                {
                    Row      = Convert.ToInt32(cmd.ExecuteScalar());
                    this.AID = Row;
                }
                else
                {
                    Row = cmd.ExecuteNonQuery();
                    //this.CategoryID = Row;
                }

                Accounts adObj = new Accounts();

                foreach (var item in adobj)
                {
                    adObj            = new Accounts();
                    adObj.ACID       = Row;
                    adObj.ADDate     = item.ADDate;
                    adObj.ADAmount   = item.ADAmount;
                    adObj.CRLedgerId = item.CRLedgerId;
                    adObj.DRLedgerId = item.DRLedgerId;
                    adObj.ADGroupId  = item.ADGroupId;
                    adObj.ADOrgId    = item.AOrgId;
                    adObj.ADSave();
                }
            }
            catch (Exception e) { e.ToString(); }
            finally { cmd.Dispose(); con.Con.Close(); }


            return(Row);
        }
示例#2
0
        public int SaveGeneral()
        {
            int        Row = 0;
            DBCon      con = new DBCon();
            SqlCommand cmd = null;

            Accounts ACDetails = Accounts.GetAll().Where(w => (w.ACRLedgerId == CRLedgerId ||
                                                               w.ACRLedgerId == DRLedgerId) && w.EntryType == Entrytype).LastOrDefault();

            if (ACDetails != null)
            {
                EntryNo = ACDetails.EntryNo + 1;
            }
            else
            {
                EntryNo = EntryNo + 1;
            }
            Ledger LedgerDetails = Ledger.GetAll().Where(w => w.ID == CRLedgerId ||
                                                         w.ID == DRLedgerId).FirstOrDefault();

            if (CRAmount > 0)
            {
                CRLedgerId = CRLedgerId;
                DRLedgerId = 0;
            }
            else
            {
                DRLedgerId = CRLedgerId;
                CRLedgerId = 0;
            }

            if (this.Entrytype == "1")
            {
                this.Entrytype = "Payment";
            }
            if (this.Entrytype == "2")
            {
                this.Entrytype = "Receipt";
            }
            if (this.Entrytype == "3")
            {
                this.Entrytype = "Contra Entry";
            }
            if (this.Entrytype == "4")
            {
                this.Entrytype = "Journal Entry";
            }
            if (this.Entrytype == "5")
            {
                this.Entrytype = "Sale";
            }
            if (this.Entrytype == "6")
            {
                this.Entrytype = "Purchase";
            }

            try
            {
                string Quary = "";
                if (this.AID == 0)
                {
                    Quary = "Insert Into ACAccount Values (@Date,@DRAmount,@CRAmount,@Narration,@Balance,@CRGroupId,@OrgId,@DRGroupId,@CRLedgerId,@DRLedgerId,@EntryNo,@EntryType,@ReceiptID);SELECT SCOPE_IDENTITY();";
                }
                else
                {
                    Quary = "Update ACAccount Set Date=@Date,DRAmount=@DRAmount,CRAmount=@CRAmount,Narration=@Narration,Balance=@Balance,CRGroupId=@CRGroupId,OrgId=@OrgId,DRGroupId=@DRGroupId,CRLedgerId=@CRLedgerId,DRLedgerId=@DRLedgerId,EntryNo=@EntryNo,EntryType=@EntryType,ReceiptID=@ReceiptID where AID=@AID";
                }
                cmd = new SqlCommand(Quary, con.Con);
                cmd.Parameters.AddWithValue("@AID", this.AID);
                cmd.Parameters.AddWithValue("@Date", this.Date);
                cmd.Parameters.AddWithValue("@DRAmount", this.DRAmount);
                cmd.Parameters.AddWithValue("@CRAmount", this.CRAmount);
                cmd.Parameters.AddWithValue("@Narration", this.Narration);
                cmd.Parameters.AddWithValue("@Balance", this.Balance);
                cmd.Parameters.AddWithValue("@CRGroupId", LedgerDetails.ParentGroup);
                cmd.Parameters.AddWithValue("@OrgId", LedgerDetails.OrgId);
                cmd.Parameters.AddWithValue("@DRGroupId", LedgerDetails.ParentGroup);
                cmd.Parameters.AddWithValue("@CRLedgerId", this.CRLedgerId);
                cmd.Parameters.AddWithValue("@DRLedgerId", this.DRLedgerId);
                cmd.Parameters.AddWithValue("@EntryNo", this.EntryNo);
                cmd.Parameters.AddWithValue("@EntryType", this.Entrytype);
                cmd.Parameters.AddWithValue("@ReceiptID", this.ReceiptID);


                if (this.AID == 0)
                {
                    Row      = Convert.ToInt32(cmd.ExecuteScalar());
                    this.AID = Row;
                }
                else
                {
                    Row = cmd.ExecuteNonQuery();
                    //this.CategoryID = Row;
                }
            }
            catch (Exception e) { e.ToString(); }
            finally { cmd.Dispose(); con.Con.Close(); }
            return(Row);
        }
示例#3
0
        public static List <Accounts> GetLedgerWiseData(int ID, string Name)
        {
            DBCon           con         = new DBCon();
            SqlCommand      cmd         = null;
            SqlDataReader   SDR         = null;
            Accounts        OBJ         = new Accounts();
            List <Accounts> AccountList = new List <Accounts>();

            try
            {
                if (Name == "Customer")
                {
                    List <Receipt> GetAllReceipt = Receipt.GetAllList(0, 0).ToList();
                    for (int i = 0; i < GetAllReceipt.Count; i++)
                    {
                        OBJ = new Accounts();
                        if (GetAllReceipt[i].Particular == "Opening Balance")
                        {
                            OBJ.Date        = GetAllReceipt[i].Date;
                            OBJ.ReceiptType = "";
                            OBJ.Type        = "";
                            OBJ.Narration   = GetAllReceipt[i].Particular;
                            OBJ.CRAmount    = GetAllReceipt[i].Amount;
                            OBJ.Balance     = (GetAllReceipt[i].Balance + OBJ.CRAmount) - OBJ.DRAmount;
                            AccountList.Add(OBJ);
                        }
                        else
                        {
                            OBJ.Date        = GetAllReceipt[i].Date;
                            OBJ.ReceiptType = "Receipt";
                            OBJ.Type        = "R" + GetAllReceipt[i].EntryNo.ToString();
                            OBJ.Narration   = GetAllReceipt[i].Particular;
                            OBJ.CRAmount    = GetAllReceipt[i].Amount;
                            OBJ.Balance     = (GetAllReceipt[i - 1].Balance + OBJ.CRAmount) - OBJ.DRAmount;


                            AccountList.Add(OBJ);
                        }
                    }
                }
                else if (Name == "Paytm")
                {
                    List <Receipt> GetAllReceipt = Receipt.GetAllList(0, 0).ToList();
                    for (int i = 0; i < GetAllReceipt.Count; i++)
                    {
                        OBJ = new Accounts();
                        if (GetAllReceipt[i].Particular == "Opening Balance")
                        {
                            OBJ.Date        = GetAllReceipt[i].Date;
                            OBJ.ReceiptType = "";
                            OBJ.Type        = "";
                            OBJ.Narration   = GetAllReceipt[i].Particular;
                            OBJ.DRAmount    = GetAllReceipt[i].Amount;

                            OBJ.Balance = (GetAllReceipt[i].Balance - OBJ.DRAmount) + OBJ.CRAmount;

                            AccountList.Add(OBJ);
                        }
                        else
                        {
                            OBJ.Date        = GetAllReceipt[i].Date;
                            OBJ.ReceiptType = "Receipt";
                            OBJ.Type        = "R" + GetAllReceipt[i].EntryNo.ToString();
                            OBJ.Narration   = GetAllReceipt[i].Particular;
                            OBJ.DRAmount    = GetAllReceipt[i].Amount;
                            OBJ.Balance     = (AccountList[i - 1].Balance - OBJ.DRAmount) + OBJ.CRAmount;

                            AccountList.Add(OBJ);
                        }
                    }
                }
                else
                {
                    List <Accounts> REList = Accounts.GetAll().Where(w => w.CRLedgerId == ID || w.DRLedgerId == ID).OrderBy(o => o.Date).ToList();


                    for (int i = 0; i < REList.Count; i++)
                    {
                        OBJ             = new Accounts();
                        OBJ.Date        = REList[i].Date;
                        OBJ.ReceiptType = REList[i].EntryType;
                        if (REList[i].EntryType == "Receipt")
                        {
                            OBJ.Type = "R" + REList[i].EntryNo.ToString();
                        }
                        if (REList[i].EntryType == "Sale")
                        {
                            OBJ.Type = "S" + REList[i].EntryNo.ToString();
                        }
                        if (REList[i].EntryType == "Journal")
                        {
                            OBJ.Type = "J" + REList[i].EntryNo.ToString();
                        }
                        if (REList[i].EntryType == "Payment")
                        {
                            OBJ.Type = "P" + REList[i].EntryNo.ToString();
                        }
                        OBJ.Narration = REList[i].Narration;
                        OBJ.DRAmount  = REList[i].CRAmount;
                        OBJ.CRAmount  = REList[i].DRAmount;
                        if (OBJ.CRAmount > 0)
                        {
                            OBJ.Balance = REList[i].Balance + OBJ.CRAmount;
                        }
                        else
                        {
                            OBJ.Balance = REList[i].Balance - OBJ.CRAmount;
                        }

                        AccountList.Add(OBJ);
                    }
                }
            }
            catch (Exception e) { e.ToString(); }

            return(AccountList);
        }