Esempio n. 1
0
    public static CalculateAll CalculateTotalAmount(DataTable dtItems, DataTable dtSundri)
    {
        CalculateAll cal = new CalculateAll();

        if (dtItems != null)
        {
            DataTable dtGrdItems = (DataTable)(dtItems);

            foreach (DataRow item in dtGrdItems.Rows)
            {
                cal.IGST         += CommonCls.ConvertDecimalZero(item["IGSTTaxAmt"].ToString());
                cal.SGST         += CommonCls.ConvertDecimalZero(item["SGSTTaxAmt"].ToString());
                cal.CGST         += CommonCls.ConvertDecimalZero(item["CGSTTaxAmt"].ToString());
                cal.CESS         += CommonCls.ConvertDecimalZero(item["CESSTaxAmt"].ToString());
                cal.ItemAmount   += CommonCls.ConvertDecimalZero(item["ItemAmount"].ToString());
                cal.ItemTaxable  += CommonCls.ConvertDecimalZero(item["NetAmt"].ToString());
                cal.ItemDiscount += CommonCls.ConvertDecimalZero(item["DiscountAmt"].ToString());
            }
        }

        decimal SundriAmt = 0;

        if (dtSundri != null)
        {
            foreach (DataRow item in dtSundri.Rows)
            {
                if (item["SundriInd"].ToString() == "Add") //For Sundri Amount Add
                {
                    SundriAmt += CommonCls.ConvertDecimalZero(item["SundriAmt"].ToString());
                }
                else if (item["SundriInd"].ToString() == "Less") //For Sundri Amount Less
                {
                    SundriAmt -= CommonCls.ConvertDecimalZero(item["SundriAmt"].ToString());
                }
            }
            cal.TotalSundriAddLess = SundriAmt;
        }
        //cal.TotalGross = cal.ItemTaxable;
        //cal.TotalAllNet = (cal.TotalTaxable + cal.ItemTaxable + cal.TotalSundriAddLess);
        cal.TotalGross   = Math.Round((cal.ItemAmount - cal.ItemDiscount), 2);
        cal.TotalTaxable = Math.Round((cal.IGST + cal.SGST + cal.CGST + cal.CESS), 2);
        cal.TotalAllNet  = Math.Round((cal.TotalGross + cal.TotalTaxable + cal.TotalSundriAddLess), 2);

        return(cal);
    }
 private void CalCulateRevisedBudgetAmt()
 {
     if (txtActualUptoBudgetAmtDr.Text == "" && txtPropLastQtrBudgetAmtDr.Text == "")
     {
         txtSanc2BudgetAmtDr.Text = "";
     }
     else
     {
         decimal Sanc2BudgetAmtDr = (CommonCls.ConvertDecimalZero(txtActualUptoBudgetAmtDr.Text) + CommonCls.ConvertDecimalZero(txtPropLastQtrBudgetAmtDr.Text));
         txtSanc2BudgetAmtDr.Text = (Sanc2BudgetAmtDr).ToString();
     }
     if (txtActualUptoBudgetAmtCr.Text == "" && txtPropLastQtrBudgetAmtCr.Text == "")
     {
         txtSanc2BudgetAmtDr.Text = "";
     }
     else
     {
         decimal Sanc2BudgetAmtCr = (CommonCls.ConvertDecimalZero(txtActualUptoBudgetAmtCr.Text) + CommonCls.ConvertDecimalZero(txtPropLastQtrBudgetAmtCr.Text));
         txtSanc2BudgetAmtCr.Text = (Sanc2BudgetAmtCr).ToString();
     }
 }
    void BindItemOSEGrid()
    {
        DataTable dtItemOSE = new DataTable();

        if (ViewState["dtItemOSE"] == null)
        {
            dtItemOSE = DtItemOSESchema();
        }
        else
        {
            dtItemOSE = (DataTable)ViewState["dtItemOSE"];
        }

        DataRow DrItemOSE = dtItemOSE.NewRow();

        DrItemOSE["OrgId"]         = Convert.ToInt32(GlobalSession.OrgID);
        DrItemOSE["ItemID"]        = 0;
        DrItemOSE["WarehouseId"]   = Convert.ToInt32(ddlWarehouse.SelectedValue);
        DrItemOSE["WareHouseName"] = ddlWarehouse.SelectedItem.Text;
        DrItemOSE["OpeningUnit"]   = CommonCls.ConvertIntZero(ddlPriUnit.SelectedValue);//ddlItemUnit.SelectedValue;
        DrItemOSE["OpeningQty"]    = CommonCls.ConvertDecimalZero(txtOpeningQty.Text);
        if (GlobalSession.StockMaintaineByMinorUnit)
        {
            DrItemOSE["OpeningMinorUnit"] = CommonCls.ConvertIntZero(ddlSecUnit.SelectedValue);//ddlMinorUnit.SelectedValue;
            DrItemOSE["OpeningMinorQty"]  = CommonCls.ConvertDecimalZero(txtSecQty.Text);
        }
        else
        {
            DrItemOSE["OpeningMinorUnit"] = 0;
            DrItemOSE["OpeningMinorQty"]  = 0;
        }
        DrItemOSE["OpRate"] = CommonCls.ConvertDecimalZero(txtOpeningRate.Text);
        DrItemOSE["OpDate"] = CommonCls.ConvertToDate(txtOpeningDate.Text);
        dtItemOSE.Rows.Add(DrItemOSE);
        grdItemMaster.DataSource = ViewState["dtItemOSE"] = dtItemOSE;
        grdItemMaster.DataBind();
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            if (string.IsNullOrEmpty(txtSectionName.Text))
            {
                ShowMessage("Select Section Name.", false);
                txtSectionName.Focus();
                return;
            }

            if (ddlSubSection.SelectedValue == "0")
            {
                ShowMessage("Select Sub-Section Name.", false);
                ddlSubSection.Focus();
                return;
            }


            if (string.IsNullOrEmpty(txtSubSection.Text))
            {
                ShowMessage("Select Cost Centre Name.", false);
                txtSubSection.Focus();
                return;
            }

            if (string.IsNullOrEmpty(txtBudgetHead.Text))
            {
                ShowMessage("Select Budget Head Name.", false);
                txtBudgetHead.Focus();
                return;
            }
            CalCulateRevisedBudgetAmt();
            objNewBudgetAmountModel              = new NewBudgetAmountModel();
            objNewBudgetAmountModel.Ind          = 21;
            objNewBudgetAmountModel.OrgID        = GlobalSession.OrgID;
            objNewBudgetAmountModel.BrID         = GlobalSession.BrID;
            objNewBudgetAmountModel.YrCode       = GlobalSession.BudgetYrCD;
            objNewBudgetAmountModel.SectionCD    = 0;
            objNewBudgetAmountModel.SubSectionCD = CommonCls.ConvertIntZero(SubSectionID);
            objNewBudgetAmountModel.BudgetHeadCD = CommonCls.ConvertIntZero(BudgetHeadID);
            objNewBudgetAmountModel.SecCode      = CommonCls.ConvertIntZero(SectionID);

            objNewBudgetAmountModel.UserID = GlobalSession.UserID;
            objNewBudgetAmountModel.IP     = "";


            //Current Year Capital
            if (txtPropBudgetCapitalAmtDr.Text == "" && txtPropBudgetCapitalAmtDr.Enabled == true)
            {
                objNewBudgetAmountModel.PropBudgetCapitalAmtDr = -1;
            }
            else
            {
                objNewBudgetAmountModel.PropBudgetCapitalAmtDr = CommonCls.ConvertDecimalZero(txtPropBudgetCapitalAmtDr.Text);
            }

            if (txtPropBudgetCapitalAmtCr.Text == "" && txtPropBudgetCapitalAmtCr.Enabled == true)
            {
                objNewBudgetAmountModel.PropBudgetCapitalAmtCr = -1;
            }
            else
            {
                objNewBudgetAmountModel.PropBudgetCapitalAmtCr = CommonCls.ConvertDecimalZero(txtPropBudgetCapitalAmtCr.Text);
            }

            //Current Year Revenue
            if (txtPropBudgetRevenueAmtDr.Text == "" && txtPropBudgetRevenueAmtDr.Enabled == true)
            {
                objNewBudgetAmountModel.PropBudgetRevenueAmtDr = -1;
            }
            else
            {
                objNewBudgetAmountModel.PropBudgetRevenueAmtDr = CommonCls.ConvertDecimalZero(txtPropBudgetRevenueAmtDr.Text);
            }

            if (txtPropBudgetRevenueAmtCr.Text == "" && txtPropBudgetRevenueAmtCr.Enabled == true)
            {
                objNewBudgetAmountModel.PropBudgetRevenueAmtCr = -1;
            }
            else
            {
                objNewBudgetAmountModel.PropBudgetRevenueAmtCr = CommonCls.ConvertDecimalZero(txtPropBudgetRevenueAmtCr.Text);
            }


            // Propose Budget Amt
            if (txtProp2BudgetAmtDr.Text == "" && txtProp2BudgetAmtDr.Enabled == true)
            {
                objNewBudgetAmountModel.Prop2BudgetAmtDr = -1;
            }
            else
            {
                objNewBudgetAmountModel.Prop2BudgetAmtDr = CommonCls.ConvertDecimalZero(txtProp2BudgetAmtDr.Text);
            }


            if (txtProp2BudgetAmtCr.Text == "" && txtProp2BudgetAmtCr.Enabled == true)
            {
                objNewBudgetAmountModel.Prop2BudgetAmtCr = -1;
            }
            else
            {
                objNewBudgetAmountModel.Prop2BudgetAmtCr = CommonCls.ConvertDecimalZero(txtProp2BudgetAmtCr.Text);
            }


            //Actual Busget Amt

            if (txtActualUptoBudgetAmtCr.Text == "" && txtActualUptoBudgetAmtCr.Enabled == true)
            {
                objNewBudgetAmountModel.ActualUptoBudgetAmtCr = -1;
            }
            else
            {
                objNewBudgetAmountModel.ActualUptoBudgetAmtCr = CommonCls.ConvertDecimalZero(txtActualUptoBudgetAmtCr.Text);
            }

            if (txtActualUptoBudgetAmtDr.Text == "" && txtActualUptoBudgetAmtDr.Enabled == true)
            {
                objNewBudgetAmountModel.ActualUptoBudgetAmtDr = -1;
            }
            else
            {
                objNewBudgetAmountModel.ActualUptoBudgetAmtDr = CommonCls.ConvertDecimalZero(txtActualUptoBudgetAmtDr.Text);
            }


            //Qtr Amt

            if (txtPropLastQtrBudgetAmtCr.Text == "" && txtPropLastQtrBudgetAmtCr.Enabled == true)
            {
                objNewBudgetAmountModel.PropLastQtrBudgetAmtCr = -1;
            }
            else
            {
                objNewBudgetAmountModel.PropLastQtrBudgetAmtCr = CommonCls.ConvertDecimalZero(txtPropLastQtrBudgetAmtCr.Text);
            }


            if (txtPropLastQtrBudgetAmtDr.Text == "" && txtPropLastQtrBudgetAmtDr.Enabled == true)
            {
                objNewBudgetAmountModel.PropLastQtrBudgetAmtDr = -1;
            }
            else
            {
                objNewBudgetAmountModel.PropLastQtrBudgetAmtDr = CommonCls.ConvertDecimalZero(txtPropLastQtrBudgetAmtDr.Text);
            }


            //Revised
            //if (txtSanc2BudgetAmtCr.Text == "" && txtSanc2BudgetAmtCr.Enabled == true)
            //    objNewBudgetAmountModel.Sanc2BudgetAmtCr = -1;
            //else
            //    objNewBudgetAmountModel.Sanc2BudgetAmtCr = CommonCls.ConvertDecimalZero(txtSanc2BudgetAmtCr.Text);

            //if (txtSanc2BudgetAmtDr.Text == "" && txtSanc2BudgetAmtDr.Enabled == true)
            //    objNewBudgetAmountModel.Sanc2BudgetAmtDr = -1;
            //else
            //    objNewBudgetAmountModel.Sanc2BudgetAmtDr = CommonCls.ConvertDecimalZero(txtSanc2BudgetAmtDr.Text);

            objNewBudgetAmountModel.Sanc2BudgetAmtCr = (CommonCls.ConvertDecimalZero(objNewBudgetAmountModel.ActualUptoBudgetAmtCr) + CommonCls.ConvertDecimalZero(objNewBudgetAmountModel.PropLastQtrBudgetAmtCr));


            objNewBudgetAmountModel.Sanc2BudgetAmtDr = (CommonCls.ConvertDecimalZero(objNewBudgetAmountModel.ActualUptoBudgetAmtDr) + CommonCls.ConvertDecimalZero(objNewBudgetAmountModel.PropLastQtrBudgetAmtDr));



            if (txtPropBudgetCapitalAmtCr.Text == "" && txtPropBudgetRevenueAmtCr.Text == "" && txtPropBudgetCapitalAmtCr.Enabled == true && txtPropBudgetRevenueAmtCr.Enabled == true)
            {
                objNewBudgetAmountModel.PropBudgetAmtCr = -1;
            }
            else
            {
                decimal PropBudgetAmtCr = (CommonCls.ConvertDecimalZero(txtPropBudgetCapitalAmtCr.Text) + CommonCls.ConvertDecimalZero(txtPropBudgetRevenueAmtCr.Text));
                objNewBudgetAmountModel.PropBudgetAmtCr = CommonCls.ConvertDecimalZero(PropBudgetAmtCr);
            }


            if (txtPropBudgetCapitalAmtDr.Text == "" && txtPropBudgetRevenueAmtDr.Text == "" && txtPropBudgetCapitalAmtDr.Enabled == true && txtPropBudgetRevenueAmtDr.Enabled == true)
            {
                objNewBudgetAmountModel.PropBudgetAmtDr = -1;
            }
            else
            {
                decimal PropBudgetAmtDr = (CommonCls.ConvertDecimalZero(txtPropBudgetCapitalAmtDr.Text) + CommonCls.ConvertDecimalZero(txtPropBudgetRevenueAmtDr.Text));
                objNewBudgetAmountModel.PropBudgetAmtDr = CommonCls.ConvertDecimalZero(PropBudgetAmtDr);
            }

            //objNewBudgetAmountModel.PropBudgetAmtCr = CommonCls.ConvertDecimalZero(txtPropBudgetCapitalAmtCr.Text + txtPropBudgetRevenueAmtCr.Text);
            //objNewBudgetAmountModel.PropBudgetAmtDr = CommonCls.ConvertDecimalZero(txtPropBudgetCapitalAmtDr.Text + txtPropBudgetRevenueAmtDr.Text);

            string uri = string.Format("NewBudgetAmount/SaveBudget");

            DataTable dtOpeningBalance = CommonCls.ApiPostDataTable(uri, objNewBudgetAmountModel);
            if (dtOpeningBalance.Rows.Count > 0)
            {
                ShowMessage("Record Save successfully.", true);
                ClearAll();
            }
            else
            {
                ShowMessage("Record Not Save successfully.", false);
            }
        }
        catch (Exception ex)
        {
            ShowMessage(ex.Message, false);
        }
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        try
        {
            lblmsg.Text = lblmsg.CssClass = "";

            if (CommonCls.ConvertIntZero(ddlItemName.SelectedValue) == 0)
            {
                ddlItemName.Focus();
                ShowMessage("Fill Item Name..!", false);
                return;
            }
            if (CommonCls.ConvertIntZero(ddlwarehouse.SelectedValue) == 0)
            {
                ddlwarehouse.Focus();
                ShowMessage("Select WareHouse ..!", false);
                return;
            }
            if (CommonCls.ConvertDecimalZero(txtPriQty.Text) == 0)
            {
                txtPriQty.Focus();
                ShowMessage("Select Item Opening Quantity ..!", false);
                return;
            }
            if (CommonCls.ConvertDecimalZero(txtPriQty.Text) == 0)
            {
                txtPriQty.Focus();
                txtPriQty.Text = "";
                ShowMessage("Enter Opening Item Quantity..!", false);
                return;
            }
            if (CommonCls.ConvertDecimalZero(txtOpRate.Text) == 0)
            {
                txtOpRate.Focus();
                txtOpRate.Text = "";
                ShowMessage("Enter Item Rate..! ", false);
                return;
            }

            if (VsDtOpenStock == null)
            {
                VsDtOpenStock = createdtGrdDT();
            }


            if (VsDtOpenStock.Rows.Count > 0)
            {
                foreach (DataRow row in VsDtOpenStock.Rows)
                {
                    //decimal opRate = Convert.ToDecimal(row["OpRate"].ToString());
                    //int itemID = Convert.ToInt32(row["ItemID"].ToString());
                    //int Warehousetext = Convert.ToInt32(row["WareHouseId"].ToString());
                    decimal opRate        = Convert.ToDecimal(row["ItemOpeningRate"].ToString());
                    int     itemID        = Convert.ToInt32(row["ItemUnitID"].ToString());
                    int     Warehousetext = Convert.ToInt32(row["WareHouseID"].ToString());
                    if (Convert.ToInt32(ddlItemName.SelectedValue) == itemID && opRate == Convert.ToDecimal(txtOpRate.Text) && Warehousetext == Convert.ToInt32(ddlwarehouse.SelectedValue))
                    {
                        ShowMessage("Rate allready exist for this item.", false);
                        return;
                    }
                }
            }
            DataRow dr = VsDtOpenStock.NewRow();
            #region Old
            //dr["OrgId"] = GlobalSession.OrgID;
            //dr["ItemID"] = ddlItemName.SelectedValue;
            //dr["WareHouseId"] = ddlwarehouse.SelectedItem.Value;
            //dr["WareHouseName"] = ddlwarehouse.SelectedItem.Text;
            //dr["OpeningUnit"] = ddlPriUnit.SelectedValue;
            //dr["OpeningQty"] = txtPriQty.Text;
            //if (ddlsecunit.SelectedValue == "0")
            //{
            //    dr["OpeningMinorUnit"] = 0;
            //}
            //else
            //{
            //    dr["OpeningMinorUnit"] = ddlsecunit.SelectedValue;
            //}

            //dr["OpeningMinorQty"] = txtsecQty.Text;
            //dr["OpRate"] = txtOpRate.Text;
            //dr["OpDate"] = CommonCls.ConvertToDate(txtDate.Text);
            #endregion

            dr["CompanyID"]      = GlobalSession.OrgID;
            dr["ItemUnitID"]     = ddlItemName.SelectedValue;
            dr["WareHouseID"]    = ddlwarehouse.SelectedItem.Value;
            dr["Address"]        = ddlwarehouse.SelectedItem.Text;
            dr["ItemUnitID"]     = ddlPriUnit.SelectedValue;
            dr["ItemOpeningQty"] = txtPriQty.Text;
            if (ddlsecunit.SelectedValue == "0")
            {
                dr["ItemMinorUnitID"] = 0;
            }
            else
            {
                dr["ItemMinorUnitID"] = ddlsecunit.SelectedValue;
            }

            dr["ItemMinorUnitQty"] = "0";
            dr["ItemOpeningRate"]  = txtOpRate.Text;
            dr["ItemOpeningDate"]  = CommonCls.ConvertToDate(txtDate.Text);
            VsDtOpenStock.Rows.Add(dr);
            gridOpenStock.DataSource = VsDtOpenStock;
            gridOpenStock.DataBind();
            clearGrid();
        }
        catch (Exception ex)
        {
            ShowMessage(ex.Message, false);
        }
    }
Esempio n. 6
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        lblMsg.Text = lblMsg.CssClass = "";
        bool IsValid = ValidationBtnSave();

        if (!IsValid)
        {
            return;
        }


        bool chkUncheck = false;

        foreach (GridViewRow grdRow in grdReportFormats.Rows)
        {
            CheckBox chkSelectOnce = (CheckBox)grdRow.FindControl("chkSelectOnce");
            if (chkSelectOnce.Checked == true)
            {
                hfFormatID.Value = ((Label)grdRow.FindControl("lblFormatID")).Text;
                chkUncheck       = true;
                break;
            }
        }

        objPCModel = new ProfileCreationModel();

        objPCModel.Ind             = 1;
        objPCModel.CompName        = txtCompanyName.Text;
        objPCModel.ShortName       = txtShortName.Text;
        objPCModel.OrgType         = Convert.ToInt32(ddlOrgType.SelectedValue);
        objPCModel.BusiNature      = Convert.ToInt32(ddlBussiNature.SelectedValue);
        objPCModel.BusiType        = Convert.ToInt32(ddlBussiType.SelectedValue);
        objPCModel.Addr            = txtAddress.Text;
        objPCModel.City            = txtCityCompany.Text;
        objPCModel.State           = Convert.ToInt32(ddlStateCompany.SelectedValue);
        objPCModel.Pin             = Convert.ToInt32(txtPincodeCompany.Text);
        objPCModel.Phone           = txtLandLineNo.Text;
        objPCModel.Fax             = txtFaxNo.Text;
        objPCModel.EMail           = txtEmail.Text;
        objPCModel.PAN             = txtPanNo.Text;
        objPCModel.TAN             = txtTanNo.Text;
        objPCModel.CIN             = txtCINNo.Text;
        objPCModel.IECode          = txtImportExportCode.Text;
        objPCModel.ExportCtg       = 0;
        objPCModel.ContactName     = txtPersonName.Text;
        objPCModel.ContactDesg     = txtDesiPerson.Text;
        objPCModel.ContactEmail    = txtEmailPerson.Text;
        objPCModel.ContactMobile   = txtMobileNoPerson.Text;
        objPCModel.AltPerson       = txtPersonNameAlter.Text;
        objPCModel.AltPersonDesg   = txtDesiPersonAlter.Text;
        objPCModel.AltPersonEmail  = txtEmailPersonAlter.Text;
        objPCModel.AltMobile       = txtMobileNoPersonAlter.Text;
        objPCModel.Composition     = Convert.ToInt32(ddlComposiOpted.SelectedValue);
        objPCModel.CompositionDate = CommonCls.ConvertToDate(txtCompoEffDate.Text);
        objPCModel.GSTIN           = string.IsNullOrEmpty(txtGSTIN.Text) ? "" : txtGSTIN.Text;
        objPCModel.RegDate         = string.IsNullOrEmpty(CommonCls.ConvertToDate(txtRegDate.Text)) ? "" : CommonCls.ConvertToDate(txtRegDate.Text);
        objPCModel.RegAddr         = string.IsNullOrEmpty(txtRegAddress.Text) ? "" : txtRegAddress.Text;
        objPCModel.RegCity         = string.IsNullOrEmpty(txtCityGSTIN.Text) ? "" : txtCityGSTIN.Text;
        objPCModel.RegState        = Convert.ToInt32(ddlStateGSTIN.SelectedValue) == 0 ? 0 : Convert.ToInt32(ddlStateGSTIN.SelectedValue);
        objPCModel.RegPin          = string.IsNullOrEmpty(txtPincodeGSTIN.Text) ? 0 : Convert.ToInt32(txtPincodeGSTIN.Text);
        objPCModel.RegAuthPerson   = txtAuthorizedSign.Text;
        objPCModel.RegAuthDesg     = txtAuthorizedDesi.Text;
        objPCModel.InvoiceNoSeries = ""; //txtInvioceSeries.Text;
        objPCModel.InvoiceNo       = 0;  //string.IsNullOrEmpty(txtStartingNo.Text) ? 0 : Convert.ToInt32(txtStartingNo.Text);
        objPCModel.YrCD            = GlobalSession.YrCD;
        objPCModel.User            = GlobalSession.UserID;
        objPCModel.IP = GlobalSession.IP;
        objPCModel.InvoiceCaption1     = txtInvoiceCaption1.Text;
        objPCModel.InvoicePrint1       = Convert.ToInt32(ddlInvoicePrint1.SelectedValue);
        objPCModel.InvoiceCaption2     = txtInvoiceCaption2.Text;
        objPCModel.InvoicePrint2       = Convert.ToInt32(ddlInvoicePrint2.SelectedValue);
        objPCModel.InvoiceCaption3     = txtInvoiceCaption3.Text;
        objPCModel.InvoicePrint3       = Convert.ToInt32(ddlInvoicePrint3.SelectedValue);
        objPCModel.InvoiceCaption4     = txtInvoiceCaption4.Text;
        objPCModel.InvoicePrint4       = Convert.ToInt32(ddlInvoicePrint4.SelectedValue);
        objPCModel.InvoiceCaption5     = txtInvoiceCaption5.Text;
        objPCModel.InvoicePrint5       = Convert.ToInt32(ddlInvoicePrint5.SelectedValue);
        objPCModel.CompanyLogo         = imgCompanyLogo.ImageUrl.Substring(imgCompanyLogo.ImageUrl.LastIndexOf("/") + 1);
        objPCModel.DtSeries            = VsDtSeries; // Series Table
        objPCModel.UnRegistered        = ddlCompanyType.SelectedValue == "1" ? 0 : ddlCompanyType.SelectedValue == "2" ? 0 : 1;
        objPCModel.CompanyType         = Convert.ToInt32(ddlCompanyType.SelectedValue);
        objPCModel.TurnoverID          = Convert.ToInt32(ddlTurnover.SelectedValue);
        objPCModel.TurnoverDescription = ddlTurnover.SelectedItem.Text;
        objPCModel.PrintHSNSACCode     = Convert.ToInt32(ddlPrintTurnover.SelectedValue);
        objPCModel.BankName            = txtBankName.Text;
        objPCModel.IFSCCode            = txtIFSCCode.Text;
        objPCModel.AccountNumber       = txtAccountNumber.Text;

        if (cbCopyType.Items[0].Selected)
        {
            objPCModel.InvoiceCopy1Header = cbCopyType.Items[0].Text;
        }
        if (cbCopyType.Items[1].Selected)
        {
            objPCModel.InvoiceCopy2Header = cbCopyType.Items[1].Text;
        }
        if (cbCopyType.Items[2].Selected)
        {
            objPCModel.InvoiceCopy3Header = cbCopyType.Items[2].Text;
        }
        if (cbCopyType.Items[3].Selected)
        {
            objPCModel.InvoiceCopy4Header = txtExtra1.Text;
        }
        if (cbCopyType.Items[4].Selected)
        {
            objPCModel.InvoiceCopy5Header = txtExtra2.Text;
        }


        objPCModel.InvoiceOnPrePrinted = Convert.ToInt32(ddlSIOnPrePrinted.SelectedValue);
        objPCModel.InvoiceCopyNo       = string.IsNullOrEmpty(txtNoPrintedCopy.Text) ? 0 : Convert.ToInt32(txtNoPrintedCopy.Text);

        objPCModel.CompositionCategoryID = ddlCompositionCategory.SelectedItem == null ? 0 : Convert.ToInt32(ddlCompositionCategory.SelectedValue);

        if (VSDTCompositionCategory != null) // First Time DataTable Create For Grid
        {
            DataRow[] row = VSDTCompositionCategory.Select("CompositionCategoryID=" + Convert.ToInt32(ddlCompositionCategory.SelectedValue));
            if (row.Count() > 0)
            {
                objPCModel.CompositionTaxRate = CommonCls.ConvertDecimalZero(row[0]["CompositionTaxRate"]);
            }
        }
        objPCModel.StcokMaintaneByMinorUnit = Convert.ToInt32(ddlStockMISecUnit.SelectedValue);

        if (chkUncheck == true)
        {
            objPCModel.ReportFormat = Convert.ToInt32(hfFormatID.Value);
        }
        else
        {
            lblMsg.Text = "Choose Invoice Format!";
            ShowMessage(lblMsg.Text, false);
            return;
        }

        if (VSTerms != null)
        {
            objPCModel.DtTerms = VSTerms;//(DataTable)ViewState["dtTerms"];
        }
        else
        {
            DataTable dtTerms = new DataTable();
            dtTerms.Columns.Add("Terms", typeof(string));
            dtTerms.Columns.Add("UserID", typeof(int));
            dtTerms.Columns.Add("IP", typeof(string));

            DataRow drTerms = dtTerms.NewRow();
            drTerms["Terms"]  = "";
            drTerms["UserID"] = GlobalSession.UserID;
            drTerms["IP"]     = GlobalSession.IP;
            dtTerms.Rows.Add(drTerms);
            objPCModel.DtTerms = dtTerms;
        }

        string    uri    = string.Format("ProfileCreation/SaveCompanyProfile");
        DataTable dtSave = CommonCls.ApiPostDataTable(uri, objPCModel);

        if (dtSave.Rows.Count > 0)
        {
            if (dtSave.Rows[0]["RecordID"].ToString() == "0")
            {
                lblMsg.Text = "Record Not Save Please Try Again.";
                ShowMessage(lblMsg.Text, false);
            }
            else if (dtSave.Rows[0]["RecordID"].ToString() == "1")
            {
                ClearAll();
                Response.Redirect("frmSuccessfullyProfileCreation.aspx?ProfileCreation=" + "Profile Create Successfully!&&OrgName=" + GlobalSession.OrgName);
            }
            else if (dtSave.Rows[0]["RecordID"].ToString() == "2")
            {
                lblMsg.Text = "Duplicate Record.";
                ShowMessage(lblMsg.Text, false);
                txtCompanyName.Focus();
            }
        }
        else
        {
            lblMsg.Text = "Record Not Save Please Try Again.";
            ShowMessage(lblMsg.Text, false);
        }
    }
    bool ValidationBtnSave()
    {
        if (string.IsNullOrEmpty(txtItemName.Text))
        {
            txtItemName.Focus();
            ShowMessage("Enter Item Name.", false);
            return(false);
        }
        if (ddlItemUnit.SelectedValue == "0")
        {
            ddlItemUnit.Focus();
            ShowMessage("Select Item Unit.", false);
            return(false);
        }

        if (Convert.ToInt16(ddlIsUnitInd.SelectedValue) == 1)
        {
            if (CommonCls.ConvertIntZero(ddlMinorUnit.SelectedValue) == 0)
            {
                ddlMinorUnit.Focus();
                ShowMessage("Select Item Secondary Unit.", false);
                return(false);
            }

            //if (CommonCls.ConvertDecimalZero(txtMinorUnitQty.Text) == 0)
            //{
            //    txtMinorUnitQty.Focus();
            //    ShowMessage("Enter Secondary Unit Qty.", false);
            //    return false;
            //}
        }
        //if (GlobalSession.StockMaintaineByMinorUnit)
        //{
        //}
        //else
        //{
        //    if (CommonCls.ConvertIntZero(ddlMinorUnit.SelectedValue) > 0)
        //    {
        //        if (CommonCls.ConvertDecimalZero(txtMinorUnitQty.Text) == 0)
        //        {
        //            txtMinorUnitQty.Focus();
        //            ShowMessage("Enter Calculation Factor.", false);
        //            return false;
        //        }
        //    }
        //}

        if (CommonCls.ConvertIntZero(ddlItemUnit.SelectedValue) == CommonCls.ConvertIntZero(ddlMinorUnit.SelectedValue))
        {
            ShowMessage("Item Primary Unit & Secondary Unit Could Not Be Same!", false);
            ddlMinorUnit.Focus();
            return(false);
        }

        if (ddlItemType.SelectedValue == "0")
        {
            ddlItemType.Focus();
            ShowMessage("Select Item Type.", false);
            return(false);
        }
        if (string.IsNullOrEmpty(txtHSNSACCode.Text))
        {
            txtHSNSACCode.Focus();
            ShowMessage("Enter HSN / SAC Code.", false);
            return(false);
        }

        if (CommonCls.ConvertDecimalZero(ddlTaxrate.SelectedValue) == -1)
        {
            ddlTaxrate.Focus();
            ShowMessage("Select Tax Rate.", false);
            return(false);
        }

        return(true);
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            if (!CommonCls.CheckGUIDIsValid())
            {
                return;
            }


            bool IsValid = ValidationBtnSave();
            if (!IsValid)
            {
                return;
            }

            objItemMaster                  = new ItemMasterModel();
            objItemMaster.Ind              = 3;
            objItemMaster.OrgID            = GlobalSession.OrgID;
            objItemMaster.YrCD             = GlobalSession.YrCD;
            objItemMaster.ItemMainID       = Convert.ToInt32(hfMainGrCode.Value);
            objItemMaster.ItemSubID        = Convert.ToInt32(hfSubGrCode.Value);
            objItemMaster.ItemMinorID      = Convert.ToInt32(ddlMinorGroup.SelectedValue);
            objItemMaster.ItemGroupID      = Convert.ToInt32(hfItemGroupID.Value);
            objItemMaster.ItemName         = txtItemName.Text;
            objItemMaster.ItemShortName    = txtShortName.Text;
            objItemMaster.ItemUnitID       = Convert.ToInt32(ddlItemUnit.SelectedValue);
            objItemMaster.GoodServiceInd   = Convert.ToInt32(ddlItemType.SelectedValue);
            objItemMaster.ItemSellingRate  = CommonCls.ConvertDecimalZero(txtSellingRate.Text);
            objItemMaster.ItemDesc         = txtItemDescription.Text == null ? "" : txtItemDescription.Text;
            objItemMaster.HSNSACCode       = txtHSNSACCode.Text; //ddlHSNSACCode.SelectedValue;
            objItemMaster.ItemCode         = Convert.ToInt64(hfMainGrCode.Value + hfSubGrCode.Value + ddlMinorGroup.SelectedValue);
            objItemMaster.User             = GlobalSession.UserID;
            objItemMaster.IP               = GlobalSession.IP;
            objItemMaster.DtItemOpening    = (DataTable)ViewState["dtItemOSE"];
            objItemMaster.ItemMinorUnitID  = CommonCls.ConvertIntZero(ddlMinorUnit.SelectedValue);
            objItemMaster.ItemMinorUnitQyt = CommonCls.ConvertDecimalZero(txtMinorUnitQty.Text);
            objItemMaster.TaxRate          = CommonCls.ConvertDecimalZero(ddlTaxrate.SelectedValue) < CommonCls.ConvertDecimalZero("0.05") ? 0 : CommonCls.ConvertDecimalZero(ddlTaxrate.SelectedValue);
            objItemMaster.TaxRateDesc      = ddlTaxrate.SelectedItem.Text;
            objItemMaster.StockMaintainInd = 0;


            if (objItemMaster.DtItemOpening != null)
            {
                if (objItemMaster.DtItemOpening.Columns.Contains("ItemID"))
                {
                    objItemMaster.DtItemOpening.Columns.Remove("ItemID");
                }
                if (objItemMaster.DtItemOpening.Columns.Contains("WareHouseName"))
                {
                    objItemMaster.DtItemOpening.Columns.Remove("WareHouseName");
                }
                //if (objItemMaster.DtItemOpening.Columns.Contains("Warehouse"))
                //{
                //    objItemMaster.DtItemOpening.Columns.Remove("Warehouse");
                //}
            }
            else
            {
                objItemMaster.DtItemOpening = DtItemOSESchema();
                DataRow drItemOpening = objItemMaster.DtItemOpening.NewRow();

                if (objItemMaster.DtItemOpening.Columns.Contains("ItemID"))
                {
                    objItemMaster.DtItemOpening.Columns.Remove("ItemID");
                }
                if (objItemMaster.DtItemOpening.Columns.Contains("WareHouseName"))
                {
                    objItemMaster.DtItemOpening.Columns.Remove("WareHouseName");
                }

                drItemOpening["OpeningUnit"]      = "";
                drItemOpening["OpeningMinorUnit"] = "";
                drItemOpening["OpeningMinorQty"]  = "";

                drItemOpening["OrgId"]       = 0;
                drItemOpening["WarehouseId"] = 0;
                drItemOpening["OpeningQty"]  = 0;
                drItemOpening["OpRate"]      = 0;
                drItemOpening["OpDate"]      = "";
                objItemMaster.DtItemOpening.Rows.Add(drItemOpening);
                //objItemMaster.DtItemOpening.Columns.Remove("Warehouse");
            }

            string    uri    = string.Format("ItemMaster/SaveItem");
            DataTable dtSave = CommonCls.ApiPostDataTable(uri, objItemMaster);
            if (dtSave.Rows.Count > 0)
            {
                if (dtSave.Rows[0]["Column1"].ToString() == "1")
                {
                    ClearAll();
                    ShowMessage("Item Save successfully.", true);
                    ddlMinorGroup.Focus();
                }
                else if (dtSave.Rows[0]["Column1"].ToString() == "2")
                {
                    ShowMessage("Item Already Added.", false);
                    txtItemName.Focus();
                }
                else if (dtSave.Rows[0]["Column1"].ToString() == "3")
                {
                    ShowMessage("Invalid HSN / SAC Code.", false);
                    txtHSNSACCode.Focus();
                }
            }
            else
            {
                ShowMessage("Record Not Save Please Try Again.", false);
            }
        }
        catch (Exception ex)
        {
            ShowMessage(ex.Message, false);
        }
    }
    bool ValidationBtnAddItemOSE()
    {
        if (ddlItemUnit.SelectedValue == ddlMinorUnit.SelectedValue)
        {
            ShowMessage("Item Primary Unit & Secondary Unit Could Not Be Same!", false);
            ddlMinorUnit.Focus();
            return(false);
        }

        if (CommonCls.ConvertIntZero(ddlItemUnit.SelectedValue) == 0)
        {
            ddlItemUnit.Focus();
            ShowMessage("Select Item Unit.", false);
            return(false);
        }
        if (ddlWarehouse.SelectedValue == "0")
        {
            ddlWarehouse.Focus();
            ShowMessage("Select Warehouse.", false);
            return(false);
        }
        if (ViewState["dtItemOSE"] != null)
        {
            DataTable dtItemOSE = (DataTable)ViewState["dtItemOSE"];
            DataRow[] rows      = dtItemOSE.Select("WarehouseId='" + ddlWarehouse.SelectedItem.Value + "' And OpeningQty='" + txtOpeningQty.Text + "' And OpRate='" + txtOpeningRate.Text + "'");
            if (rows.Count() >= 1)
            {
                ShowMessage("This Qty And Rate Alredy Added On Same Warehouse.", false); //Repeated Record Occurred
                ddlWarehouse.Focus();
                ClearAllAfterBtnAddItemOSE();
                return(false);
            }
        }
        if (CommonCls.ConvertDecimalZero(txtOpeningQty.Text) == 0)
        {
            txtOpeningQty.Focus();
            ShowMessage("Enter Opening Qty.", false);
            return(false);
        }
        if (CommonCls.ConvertDecimalZero(txtOpeningRate.Text) == 0)
        {
            txtOpeningRate.Focus();
            ShowMessage("Enter Opening Rate.", false);
            return(false);
        }

        if (GlobalSession.StockMaintaineByMinorUnit)
        {
            if (CommonCls.ConvertIntZero(txtSecQty.Text) == 0)
            {
                txtSecQty.Focus();
                ShowMessage("Enter Opening Secondary Qty.", false);
                return(false);
            }
            if (CommonCls.ConvertIntZero(ddlMinorUnit.SelectedValue) == 0)
            {
                ShowMessage("Select Secondary Unit.", false);
                ddlMinorUnit.Focus();
                return(false);
            }
        }

        if (string.IsNullOrEmpty(txtOpeningDate.Text))
        {
            txtOpeningDate.Focus();
            ShowMessage("Enter Opening Date.", false);
            return(false);
        }
        return(true);
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            if (string.IsNullOrEmpty(txtSectionName.Text))
            {
                ShowMessage("Select Section Name.", false);
                txtSectionName.Focus();
                return;
            }

            if (string.IsNullOrEmpty(txtSubSection.Text))
            {
                ShowMessage("Select Sub-Section Name.", false);
                txtSubSection.Focus();
                return;
            }

            if (string.IsNullOrEmpty(txtBudgetHead.Text))
            {
                ShowMessage("Select Budget Head Name.", false);
                txtBudgetHead.Focus();
                return;
            }
            //if (txtProposedDrAmt.Enabled == true)
            //{
            //    if (string.IsNullOrEmpty(txtProposedDrAmt.Text) || Convert.ToDecimal(txtProposedDrAmt.Text) <= 0)
            //    {
            //        ShowMessage("Enter Proposed Budget Amount 2017-2018.", false);
            //        txtProposedDrAmt.Focus();
            //        return;
            //    }
            //}



            //if (txtProposedCrAmt.Enabled == true)
            //{

            //    if (string.IsNullOrEmpty(txtProposedCrAmt.Text) || Convert.ToDecimal(txtProposedCrAmt.Text) <= 0)
            //    {
            //        ShowMessage("Enter Proposed Budget Amount 2017-2018.", false);
            //        txtProposedCrAmt.Focus();
            //        return;
            //    }

            //}

            objBudgetAmountModel        = new BudgetAmountModel();
            objBudgetAmountModel.Ind    = 2;
            objBudgetAmountModel.OrgID  = GlobalSession.OrgID;
            objBudgetAmountModel.BrID   = GlobalSession.BrID;
            objBudgetAmountModel.YrCode = GlobalSession.YrCD;
            //objBudgetAmountModel.SectionCD = CommonCls.ConvertIntZero(ddlSection.SelectedValue);
            //objBudgetAmountModel.SubSectionCD = CommonCls.ConvertIntZero(ddlSubSection.SelectedValue);
            objBudgetAmountModel.SectionCD    = CommonCls.ConvertIntZero(SectionID);
            objBudgetAmountModel.SubSectionCD = CommonCls.ConvertIntZero(SubSectionID);
            //objBudgetAmountModel.BudgetHeadCD = CommonCls.ConvertIntZero(ddlBudgetHead.SelectedValue);

            objBudgetAmountModel.BudgetHeadCD = CommonCls.ConvertIntZero(BudgetHeadID);

            objBudgetAmountModel.UserID = GlobalSession.UserID;
            objBudgetAmountModel.IP     = "";

            objBudgetAmountModel.Actual3budgetAmtDr = CommonCls.ConvertDecimalZero(txtAcutal3DrAmt.Text);
            objBudgetAmountModel.Actual3budgetAmtCr = CommonCls.ConvertDecimalZero(txtAcutal3CrAmt.Text);
            objBudgetAmountModel.Prop2BudgetAmtDr   = CommonCls.ConvertDecimalZero(txtProposed2DrAmt.Text);
            objBudgetAmountModel.Prop2BudgetAmtCr   = CommonCls.ConvertDecimalZero(txtProposed2CrAmt.Text);
            objBudgetAmountModel.Sanc2BudgetAmtDr   = CommonCls.ConvertDecimalZero(txtSanctioned2DrAmt.Text);
            objBudgetAmountModel.Sanc2BudgetAmtCr   = CommonCls.ConvertDecimalZero(txtSanctioned2CrAmt.Text);
            objBudgetAmountModel.Actual2budgetAmtDr = CommonCls.ConvertDecimalZero(txtActual2DrAmt.Text);
            objBudgetAmountModel.Actual2budgetAmtcr = CommonCls.ConvertDecimalZero(txtActual2CrAmt.Text);
            objBudgetAmountModel.PropBudgetAmtDr    = CommonCls.ConvertDecimalZero(txtProposedDrAmt.Text);
            objBudgetAmountModel.PropBudgetAmtCr    = CommonCls.ConvertDecimalZero(txtProposedCrAmt.Text);

            string uri = string.Format("BudgetAmount/SaveBudget");

            DataTable dtOpeningBalance = CommonCls.ApiPostDataTable(uri, objBudgetAmountModel);
            if (dtOpeningBalance.Rows.Count > 0)
            {
                ShowMessage("Record Save successfully.", true);
                ClearAll();
            }
            else
            {
                ShowMessage("Record Not Save successfully.", false);
            }
        }
        catch (Exception ex)
        {
            ShowMessage(ex.Message, false);
        }
    }