Exemple #1
0
        public static List <Receipt> GetData(int OrgId)
        {
            DBCon          con         = new DBCon();
            SqlCommand     cmd         = null;
            SqlDataReader  SDR         = null;
            Receipt        OBJ         = new Receipt();
            List <Receipt> ReceiptList = new List <Receipt>();

            try
            {
                List <Receipt> REList = Receipt.GetAllList(OrgId, 0).ToList();



                for (int i = 0; i < REList.Count; i++)
                {
                    OBJ = new Receipt();
                    string LName = Ledger.GetAll().Where(w => w.ID == REList[i].DRLedgerId).Select(s => s.Name).FirstOrDefault();

                    string GName = Group.GetAll().Where(w => w.ID == REList[i].DRGroupId).Select(s => s.Name).FirstOrDefault();

                    OBJ.ReceiptType = "DR";
                    OBJ.Particular  = "(L)" + LName + " >>" + " (LG) " + GName;
                    OBJ.DrAmount    = REList[i].Amount;
                    ReceiptList.Add(OBJ);

                    OBJ = new Receipt();
                    string LName1 = Ledger.GetAll().Where(w => w.ID == REList[i].CRLedgerId).Select(s => s.Name).FirstOrDefault();

                    string GName1 = Group.GetAll().Where(w => w.ID == REList[i].CRGroupId).Select(s => s.Name).FirstOrDefault();

                    OBJ.ReceiptType = "CR";
                    OBJ.Particular  = "(L)" + LName1 + " >>" + " (LG) " + GName1;
                    OBJ.CRAmount    = REList[i].Amount;
                    ReceiptList.Add(OBJ);
                }
            }
            catch (Exception e) { e.ToString(); }

            return(ReceiptList);
        }
Exemple #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);
        }