public IHttpActionResult post([FromBody] ledger ledgers)
 {
     try
     {
         if (string.IsNullOrEmpty(ledgers.name))
         {
             ModelState.AddModelError("name", "Name is Required");
         }
         if (ModelState.IsValid)
         {
             using (Count10_DevEntities entities = new Count10_DevEntities())
             {
                 ledgers.system     = ledgers.system.HasValue ? ledgers.system : false;
                 ledgers.managed    = ledgers.managed.HasValue ? ledgers.managed : false;
                 ledgers.active     = ledgers.active.HasValue ? ledgers.active : true;
                 ledgers.archived   = ledgers.archived.HasValue ? ledgers.archived : false;
                 ledgers.updated_by = ledgers.updated_by.HasValue ? ledgers.updated_by : 1;
                 ledgers.created_by = ledgers.created_by.HasValue ? ledgers.created_by : 1;
                 ledgers.created_at = DateTime.Now;
                 ledgers.updated_at = DateTime.Now;
                 entities.ledgers.Add(ledgers);
                 entities.SaveChanges();
                 var message = Request.CreateResponse(HttpStatusCode.Created, ledgers);
             }
             return(Ok(ledgers));
         }
         return(BadRequest(ModelState));
     }
     catch (Exception)
     {
         return(BadRequest(ModelState));
     }
 }
Пример #2
0
        private List <ledger> getLedgerDetails()
        {
            ledger        ldg      = new ledger();
            List <ledger> VDetails = new List <ledger>();

            try
            {
                for (int i = 0; i < grdList.Rows.Count - 2; i++)
                {
                    ldg                   = new ledger();
                    ldg.DocumentID        = grdList.Rows[i].Cells["gDocumentID"].Value.ToString();
                    ldg.VoucherNo         = Convert.ToInt32(grdList.Rows[i].Cells["VoucherNo"].Value.ToString());
                    ldg.VoucherDate       = Convert.ToDateTime(grdList.Rows[i].Cells["VoucherDate"].Value);
                    ldg.TransactionACName = grdList.Rows[i].Cells["TransactionACName"].Value.ToString();
                    ldg.Narration         = grdList.Rows[i].Cells["Narration"].Value.ToString();
                    ldg.DebitAmnt         = Convert.ToDecimal(grdList.Rows[i].Cells["DrAmt"].Value.ToString());
                    ldg.CreditAmnt        = Convert.ToDecimal(grdList.Rows[i].Cells["CrAmt"].Value);
                    VDetails.Add(ldg);
                }
            }
            catch (Exception EX)
            {
            }
            return(VDetails);
        }
Пример #3
0
        public override global::System.Data.DataSet Clone()
        {
            ledger cln = ((ledger)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
Пример #4
0
        private void grdRadioSelectWiseList_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            string columnName = grdRadioSelectWiseList.Columns[e.ColumnIndex].Name;

            try
            {
                if (columnName.Equals("Details") && e.RowIndex != grdRadioSelectWiseList.Rows.Count - 1)
                {
                    grdRadioSelectWiseList.Rows[rowIndex].DefaultCellStyle.BackColor = c;
                    c = grdRadioSelectWiseList.Rows[e.RowIndex].DefaultCellStyle.BackColor;
                    grdRadioSelectWiseList.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.CornflowerBlue;
                    rowIndex = e.RowIndex;
                    btnClose2ndGrid.Visible     = true;
                    grdDocumentWiseList.Visible = true;
                    int    opt;
                    ledger ldg   = new ledger();
                    string HText = grdRadioSelectWiseList.Columns["SelectedType"].HeaderText;
                    if (HText.Equals("Account Code"))
                    {
                        opt = 1;
                        //string str = grdRadioSelectWiseList.Rows[e.RowIndex].Cells["SelectedType"].Value.ToString();
                        ldg.AccountCode = grdRadioSelectWiseList.Rows[e.RowIndex].Cells["SelectedType"].Value.ToString();
                        ldg.AccountName = grdRadioSelectWiseList.Rows[e.RowIndex].Cells["SelectedName"].Value.ToString();
                    }
                    else if (HText.Equals("Party Code"))
                    {
                        opt = 2;
                        //string str = grdRadioSelectWiseList.Rows[e.RowIndex].Cells["SelectedType"].Value.ToString();
                        ldg.SLCode = grdRadioSelectWiseList.Rows[e.RowIndex].Cells["SelectedType"].Value.ToString();
                        ldg.SLName = grdRadioSelectWiseList.Rows[e.RowIndex].Cells["SelectedName"].Value.ToString();
                    }
                    else
                    {
                        opt = 3;
                        string str = grdRadioSelectWiseList.Rows[e.RowIndex].Cells["SelectedType"].Value.ToString();
                        str             = Utilities.convertDateStringToAnsi(str);
                        ldg.VoucherDate = Convert.ToDateTime(str);
                        ////DateTime tDate = Convert.ToDateTime("30-01-2018",);
                        ////DateTime tDate = DateTime.ParseExact("2018-01-30 00:00:00", "yyyy-MM-dd HH:mm", null);
                        //ldg.VoucherDate = DateTime.Parse(str);
                    }
                    List <ledger> ledgList = ReceiptAndPaymentDB.getDocumentWiseDetail(ldg, opt, dtFromDate.Value, dtToDate.Value);
                    btnDocWiseExportToExcel.Visible = true;
                    showDocumentWiseDetailGrid(ledgList);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("grdRadioSelectWiseList_CellContentClick() : Error - " + ex.ToString());
            }
        }
Пример #5
0
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            ledger ds = new ledger();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
Пример #6
0
        public static List <ledger> gFillSalesLedger(long vlngSLedgerType = 0, long vlngPLedgerType = 0, long vlngCash = 0)
        {
            string strSQL;

            List <ledger> ooStr = new List <ledger>();

            using (SqlConnection gcnmain = new SqlConnection(Utility.SQLConnstring()))
            {
                if (gcnmain.State == System.Data.ConnectionState.Open)
                {
                    gcnmain.Close();
                }
                try
                {
                    gcnmain.Open();
                    SqlDataReader dr;
                    SqlCommand    cmd = new SqlCommand();

                    strSQL = "SELECT LEDGER_NAME FROM ACC_LEDGER ";
                    if (vlngSLedgerType != 0)
                    {
                        strSQL = strSQL + "WHERE LEDGER_GROUP = " + vlngSLedgerType + " ";
                        strSQL = strSQL + "AND LEDGER_STATUS = 0 ";
                    }
                    strSQL          = strSQL + "ORDER BY LEDGER_NAME";
                    cmd.Connection  = gcnmain;
                    cmd.CommandText = strSQL;
                    dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        ledger ostr = new ledger();
                        ostr.LedgerName = dr["LEDGER_NAME"].ToString();
                        ooStr.Add(ostr);
                    }
                    dr.Close();
                    return(ooStr);
                }

                finally
                {
                    gcnmain.Close();
                }
            }
        }
Пример #7
0
        private List <ledger> getLedgerDetails()
        {
            ledger        ldg      = new ledger();
            List <ledger> VDetails = new List <ledger>();

            try
            {
                for (int i = 0; i < grdRadioSelectWiseList.Rows.Count - 2; i++)
                {
                    ldg            = new ledger();
                    ldg.DocumentID = grdRadioSelectWiseList.Rows[i].Cells["SelectedType"].Value.ToString();  // For Storing Selected Type of radio button
                    ldg.DebitAmnt  = Convert.ToDecimal(grdRadioSelectWiseList.Rows[i].Cells["Payment"].Value.ToString());
                    ldg.CreditAmnt = Convert.ToDecimal(grdRadioSelectWiseList.Rows[i].Cells["Receipt"].Value);
                    VDetails.Add(ldg);
                }
            }
            catch (Exception EX)
            {
            }
            return(VDetails);
        }
Пример #8
0
        private List <ledger> getLedgerDetails()
        {
            ledger        ldg      = new ledger();
            List <ledger> VDetails = new List <ledger>();

            try
            {
                for (int i = 0; i < grdTrialBalance.Rows.Count - 1; i++)
                {
                    ldg             = new ledger();
                    ldg.AccountCode = grdTrialBalance.Rows[i].Cells["AccountCode"].Value.ToString();
                    ldg.AccountName = grdTrialBalance.Rows[i].Cells["AccountName"].Value.ToString();
                    ldg.DebitAmnt   = Convert.ToDecimal(grdTrialBalance.Rows[i].Cells["DrAmt"].Value.ToString());
                    ldg.CreditAmnt  = Convert.ToDecimal(grdTrialBalance.Rows[i].Cells["CrAmt"].Value);
                    VDetails.Add(ldg);
                }
            }
            catch (Exception EX)
            {
            }
            return(VDetails);
        }
Пример #9
0
        private List <ledger> getDocumetnWiseLedgerDetails()
        {
            ledger        ldg      = new ledger();
            List <ledger> VDetails = new List <ledger>();

            try
            {
                for (int i = 0; i < grdDocumentWiseList.Rows.Count - 2; i++)
                {
                    ldg             = new ledger();
                    ldg.VoucherNo   = Convert.ToInt32(grdDocumentWiseList.Rows[i].Cells["VoucherNo"].Value.ToString());
                    ldg.VoucherDate = Convert.ToDateTime(grdDocumentWiseList.Rows[i].Cells["VoucherDate"].Value.ToString());
                    ldg.Narration   = grdDocumentWiseList.Rows[i].Cells["VoucherType"].Value.ToString(); // For Storing Voucher Type
                    ldg.DebitAmnt   = Convert.ToDecimal(grdDocumentWiseList.Rows[i].Cells["gPayment"].Value.ToString());
                    ldg.CreditAmnt  = Convert.ToDecimal(grdDocumentWiseList.Rows[i].Cells["gReceipt"].Value);
                    VDetails.Add(ldg);
                }
            }
            catch (Exception EX)
            {
            }
            return(VDetails);
        }
 public HttpResponseMessage put(int id, [FromBody] ledger ledgers)
 {
     try
     {
         using (Count10_DevEntities entities = new Count10_DevEntities())
         {
             var entity = entities.ledgers.FirstOrDefault(e => e.id == id);
             if (entity == null)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Ledger with Id = " + id.ToString() + " not found to edit"));
             }
             else
             {
                 entity.name                = ledgers.name;
                 entity.alt_name            = ledgers.alt_name;
                 entity.parent_id           = ledgers.parent_id;
                 entity.chart_of_account_id = ledgers.chart_of_account_id;
                 entity.organization_id     = ledgers.organization_id;
                 entity.cost_centre_id      = ledgers.cost_centre_id;
                 entity.currency_id         = ledgers.currency_id;
                 entity.position            = ledgers.position;
                 entity.opening_balance     = ledgers.opening_balance;
                 entity.opening_cr_dr       = ledgers.opening_cr_dr;
                 entity.current_balance     = ledgers.current_balance;
                 entity.current_cr_dr       = ledgers.current_cr_dr;
                 entity.notes               = ledgers.notes;
                 entities.SaveChanges();
                 return(Request.CreateResponse(HttpStatusCode.OK, entity));
             }
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }
Пример #11
0
        private void btnVieDetails_Click(object sender, EventArgs e)
        {
            //--------
            try
            {
                if (cmbFYID.SelectedIndex == -1)
                {
                    MessageBox.Show("Select Financial Year");
                    return;
                }
                string[] str         = cmbFYID.SelectedItem.ToString().Split(':');
                string   s           = str[0];
                string   ss          = str[1];
                string   sss         = str[2];
                DateTime FYstartDate = Convert.ToDateTime(ss.Trim());
                DateTime FYEndDate   = Convert.ToDateTime(sss.Trim());
                if (dtFromDate.Value.Date < FYstartDate.Date || dtToDate.Value.Date > FYEndDate.Date ||
                    dtToDate.Value.Date < FYstartDate.Date || dtFromDate.Value.Date > FYEndDate.Date)
                {
                    MessageBox.Show("Dates should be within the FY");
                    return;
                }

                if (dtFromDate.Value.Date > dtToDate.Value.Date)
                {
                    MessageBox.Show("From / To Date mismatch");
                    return;
                }
                balance = "";

                grdList.Visible = true;
                grdList.Rows.Clear();
                btnExportToExcel.Visible = true;
                TxtSearchNamr.Text       = "";
                lblSearch.Visible        = true;
                TxtSearchNamr.Visible    = true;
                btnCancel.Visible        = true;
                btnClose.PerformClick();
                List <string> testList = new List <string>();
                btnExportToExcel.Visible = true;
                // btnExportToPDF.Visible = true;
                btnCancel.Visible = true;
                LedgerDB ldb = new LedgerDB();
                //get all OB for all account at FY start
                List <AccountOBdetail> accObList = AccountOBDB.getAccountOBListForPericualrFY(s);  //10 rows

                //Accountwise debit total and credit total till from date
                List <ledger> ledgerListFromdt = LedgerDB.getAccountWiseDrCrTotTillFromDate(FYstartDate, dtFromDate.Value); //12rows


                foreach (ledger ldg in ledgerListFromdt)
                {
                    AccountOBdetail accList = accObList.FirstOrDefault(acc => acc.AccountCode == ldg.AccountCode);
                    if (accList == null) //If New Account found
                    {
                        AccountOBdetail accNew = new AccountOBdetail();
                        accNew.AccountCode = ldg.AccountCode;
                        accNew.AccountName = ldg.AccountName;
                        accNew.OBValue     = (ldg.DebitAmnt - ldg.CreditAmnt);
                        accObList.Add(accNew);
                        testList.Add(ldg.AccountCode);
                    }
                }
                foreach (AccountOBdetail acc in accObList)
                {
                    ledger ldg = ledgerListFromdt.FirstOrDefault(ldger => ldger.AccountCode == acc.AccountCode);
                    if (ldg != null && !testList.Contains(ldg.AccountCode))
                    {
                        acc.OBValue = acc.OBValue + (ldg.DebitAmnt - ldg.CreditAmnt); //updating new ob value till from date
                    }
                }
                List <ledger> ledgerListwithinperiod = LedgerDB.getAccountWiseDrCrTotWithinPeriod(dtFromDate.Value, dtToDate.Value);

                //List<ledger> LedgerList = ldb.getFilteredledger(FYstartDate, dtFromDate.Value, dtToDate.Value, txtBankAccountCode.Text);

                TotDrAmntBal = 0;
                TotCrAmntBal = 0;
                TotOBValue   = 0;
                TotDebAmnt   = 0;
                TotCredAmnt  = 0;
                int i = 0;
                //List<AccountOBdetail> acclIst = accObList.OrderBy(acc => acc.AccountName).ToList();
                foreach (AccountOBdetail acc in accObList)
                {
                    i++;
                    grdList.Rows.Add();
                    grdList.Rows[grdList.RowCount - 1].Cells["SerialNo"].Value       = grdList.RowCount;
                    grdList.Rows[grdList.RowCount - 1].Cells["AccountCode"].Value    = acc.AccountCode;
                    grdList.Rows[grdList.RowCount - 1].Cells["AccountName"].Value    = acc.AccountName;
                    grdList.Rows[grdList.RowCount - 1].Cells["OpeningBalance"].Value = acc.OBValue;
                    TotOBValue = TotOBValue + acc.OBValue;
                    ledger ldgInPeriod = ledgerListwithinperiod.FirstOrDefault(ldgr => ldgr.AccountCode == acc.AccountCode);
                    if (ldgInPeriod != null)
                    {
                        grdList.Rows[grdList.RowCount - 1].Cells["DebitAmount"].Value = ldgInPeriod.DebitAmnt;  //withing period total debit amount
                        grdList.Rows[grdList.RowCount - 1].Cells["CreditAmout"].Value = ldgInPeriod.CreditAmnt; ////withing period total credit amount

                        TotDebAmnt  = TotDebAmnt + ldgInPeriod.DebitAmnt;
                        TotCredAmnt = TotCredAmnt + ldgInPeriod.CreditAmnt;
                        grdList.Rows[grdList.RowCount - 1].Cells["gBalance"].Value = acc.OBValue + (ldgInPeriod.DebitAmnt - ldgInPeriod.CreditAmnt);
                    }
                    else
                    {
                        //No transaction found within time period
                        grdList.Rows[grdList.RowCount - 1].Cells["DebitAmount"].Value = Convert.ToDecimal(0);
                        grdList.Rows[grdList.RowCount - 1].Cells["CreditAmout"].Value = Convert.ToDecimal(0);
                        grdList.Rows[grdList.RowCount - 1].Cells["gBalance"].Value    = acc.OBValue;
                    }
                    decimal balancetst = Convert.ToDecimal(grdList.Rows[grdList.RowCount - 1].Cells["gBalance"].Value);
                    if (balancetst > 0)
                    {
                        grdList.Rows[grdList.RowCount - 1].Cells["DebitBalance"].Value  = balancetst;
                        grdList.Rows[grdList.RowCount - 1].Cells["CreditBalance"].Value = Convert.ToDecimal(0);
                    }
                    else
                    {
                        grdList.Rows[grdList.RowCount - 1].Cells["CreditBalance"].Value = balancetst * (-1);
                        grdList.Rows[grdList.RowCount - 1].Cells["DebitBalance"].Value  = Convert.ToDecimal(0);
                    }
                    TotDrAmntBal = TotDrAmntBal + Convert.ToDecimal(grdList.Rows[grdList.RowCount - 1].Cells["DebitBalance"].Value);
                    TotCrAmntBal = TotCrAmntBal + Convert.ToDecimal(grdList.Rows[grdList.RowCount - 1].Cells["CreditBalance"].Value);
                }
                foreach (ledger ldgrnew in ledgerListwithinperiod)
                {
                    AccountOBdetail accList = accObList.FirstOrDefault(acc => acc.AccountCode == ldgrnew.AccountCode);
                    if (accList == null) //If New Account found OB is nill
                    {
                        i++;
                        grdList.Rows.Add();
                        grdList.Rows[grdList.RowCount - 1].Cells["SerialNo"].Value       = grdList.RowCount;
                        grdList.Rows[grdList.RowCount - 1].Cells["AccountCode"].Value    = ldgrnew.AccountCode;
                        grdList.Rows[grdList.RowCount - 1].Cells["AccountName"].Value    = ldgrnew.AccountName;
                        grdList.Rows[grdList.RowCount - 1].Cells["OpeningBalance"].Value = Convert.ToDecimal(0);
                        grdList.Rows[grdList.RowCount - 1].Cells["DebitAmount"].Value    = ldgrnew.DebitAmnt;  //withing period total debit amount
                        grdList.Rows[grdList.RowCount - 1].Cells["CreditAmout"].Value    = ldgrnew.CreditAmnt; ////withing period total credit amount
                        //TotOBValue = TotOBValue + acc.OBValue;
                        TotDebAmnt  = TotDebAmnt + ldgrnew.DebitAmnt;
                        TotCredAmnt = TotCredAmnt + ldgrnew.CreditAmnt;
                        grdList.Rows[grdList.RowCount - 1].Cells["gBalance"].Value = (ldgrnew.DebitAmnt - ldgrnew.CreditAmnt);

                        decimal balancetst = Convert.ToDecimal(grdList.Rows[grdList.RowCount - 1].Cells["gBalance"].Value);
                        if (balancetst > 0)
                        {
                            grdList.Rows[grdList.RowCount - 1].Cells["DebitBalance"].Value  = balancetst;
                            grdList.Rows[grdList.RowCount - 1].Cells["CreditBalance"].Value = Convert.ToDecimal(0);
                        }
                        else
                        {
                            grdList.Rows[grdList.RowCount - 1].Cells["CreditBalance"].Value = balancetst * (-1);
                            grdList.Rows[grdList.RowCount - 1].Cells["DebitBalance"].Value  = Convert.ToDecimal(0);
                        }
                        TotDrAmntBal = TotDrAmntBal + Convert.ToDecimal(grdList.Rows[grdList.RowCount - 1].Cells["DebitBalance"].Value);
                        TotCrAmntBal = TotCrAmntBal + Convert.ToDecimal(grdList.Rows[grdList.RowCount - 1].Cells["CreditBalance"].Value);
                    }
                }
                if (i == grdList.Rows.Count)
                {
                    grdList.Rows.Add();
                    grdList.Rows[grdList.RowCount - 1].Cells["AccountName"].Value    = "Total";
                    grdList.Rows[grdList.RowCount - 1].Cells["OpeningBalance"].Value = TotOBValue;
                    grdList.Rows[grdList.RowCount - 1].Cells["DebitAmount"].Value    = TotDebAmnt;
                    grdList.Rows[grdList.RowCount - 1].Cells["CreditAmout"].Value    = TotCredAmnt;
                    grdList.Rows[grdList.RowCount - 1].Cells["CreditBalance"].Value  = TotCrAmntBal < 0 ? TotCrAmntBal * (-1) : TotCrAmntBal;
                    grdList.Rows[grdList.RowCount - 1].Cells["DebitBalance"].Value   = TotDrAmntBal < 0 ? TotDrAmntBal * (-1) : TotDrAmntBal;
                }
                chktransacted.Checked = false;
                chktransacted.Checked = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Check All ");
            }
        }