void GetReport()
    {
        try
        {
            lbl_msg.Text         = "";
            pnlHide.Visible      = true;
            Session["RouteName"] = ddlaccountno.SelectedItem.Text;
            Session["IDate"]     = DateTime.Now.AddDays(1).ToString("dd/MM/yyyy");
            vdm = new VehicleDBMgr();
            SAPdbmanger SAPvdm        = new SAPdbmanger();
            DateTime    fromdate      = DateTime.Now;
            DateTime    todate        = DateTime.Now;
            string[]    dateFromstrig = txtFromdate.Text.Split(' ');
            if (dateFromstrig.Length > 1)
            {
                if (dateFromstrig[0].Split('-').Length > 0)
                {
                    string[] dates = dateFromstrig[0].Split('-');
                    string[] times = dateFromstrig[1].Split(':');
                    fromdate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0);
                }
            }

            string[] datetostrig = txttodate.Text.Split(' ');
            if (datetostrig.Length > 1)
            {
                if (datetostrig[0].Split('-').Length > 0)
                {
                    string[] dates = datetostrig[0].Split('-');
                    string[] times = datetostrig[1].Split(':');
                    todate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0);
                }
            }


            lbl_selfromdate.Text = fromdate.ToString("dd/MM/yyyy");
            lblRoutName.Text     = ddlaccountno.SelectedItem.Text;
            Session["xporttype"] = "TallyReceipts";
            string ledger     = "";
            string ledgercode = "";
            string WHcode     = "";
            cmd = new SqlCommand("SELECT sno, ladger_dr, ladger_dr_code, brach_ledger, brach_ledger_code FROM bankaccountno_master WHERE (sno = @accountno)");
            cmd.Parameters.Add("@accountno", ddlaccountno.SelectedValue);
            DataTable dtledger = vdm.SelectQuery(cmd).Tables[0];
            if (dtledger.Rows.Count > 0)
            {
                ledger     = dtledger.Rows[0]["ladger_dr"].ToString();
                ledgercode = dtledger.Rows[0]["ladger_dr_code"].ToString();
                WHcode     = dtledger.Rows[0]["brach_ledger_code"].ToString();
            }
            cmd = new SqlCommand("SELECT  collections.sno, collectionsubdetails.sno as csno, collections.accountno, collections.remarks, collections.receiptdate, CONVERT(VARCHAR(10), collections.receiptdate, 103) AS doe,  headofaccounts_master.accountname,headofaccounts_master.accountcode, collectionsubdetails.headofaccount, collectionsubdetails.amount, collections.branch, branchmaster.receiptseries, branchmaster.whcode, collections.sapimport  FROM  collections INNER JOIN  collectionsubdetails ON collections.sno = collectionsubdetails.collectionrefno INNER JOIN headofaccounts_master ON collectionsubdetails.headofaccount = headofaccounts_master.sno INNER JOIN branchmaster ON collections.subbranch = branchmaster.branchid WHERE (collections.receiptdate BETWEEN @d1 AND @d2) AND (collections.accountno = @accountno) AND (collections.sapimport = '1')");
            cmd.Parameters.Add("@accountno", ddlaccountno.SelectedValue);
            cmd.Parameters.Add("@d1", GetLowDate(fromdate));
            cmd.Parameters.Add("@d2", GetHighDate(todate));
            DataTable dtsalescollection = vdm.SelectQuery(cmd).Tables[0];
            dtReport = new DataTable();
            dtReport.Columns.Add("Voucher Date");
            dtReport.Columns.Add("Voucher No");
            dtReport.Columns.Add("Voucher Type");
            dtReport.Columns.Add("WH Code");
            dtReport.Columns.Add("Debit Code");
            dtReport.Columns.Add("Ledger (Dr)");
            dtReport.Columns.Add("C WHCODE");
            dtReport.Columns.Add("Credit Code");
            dtReport.Columns.Add("Ledger (Cr)");
            dtReport.Columns.Add("Amount");
            dtReport.Columns.Add("Series");
            dtReport.Columns.Add("Narration");
            int i = 1;
            foreach (DataRow branch in dtsalescollection.Rows)
            {
                double num;
                string accode = branch["accountcode"].ToString();

                string amount = branch["amount"].ToString();
                sqlcmd = new SqlCommand("SELECT * FROM EMROJDTP WHERE AcctCode=@actcode AND Debit=@Debit AND CreateDate=@doe");
                sqlcmd.Parameters.Add("@doe", GetLowDate(fromdate));
                sqlcmd.Parameters.Add("@Debit", amount);
                sqlcmd.Parameters.Add("@actcode", ledgercode);
                DataTable dtJournelexist = SAPvdm.SelectQuery(sqlcmd).Tables[0];
                if (dtJournelexist.Rows.Count > 0)
                {
                }
                else
                {
                    DataRow  newrow = dtReport.NewRow();
                    string   doe    = branch["receiptdate"].ToString();
                    DateTime dtdoe  = Convert.ToDateTime(doe);
                    newrow["Voucher Date"] = dtdoe.ToString("dd-MMM-yyyy");
                    newrow["Voucher No"]   = "BANK_REC" + branch["csno"].ToString();
                    newrow["Voucher Type"] = "Bank Receipt Import";
                    newrow["Ledger (Dr)"]  = ledger;
                    if (branch["accountname"].ToString() == "")
                    {
                    }
                    else
                    {
                        newrow["WH Code"]     = WHcode;
                        newrow["Credit Code"] = branch["accountcode"].ToString();
                        newrow["Ledger (Cr)"] = branch["accountname"].ToString();
                        newrow["Debit Code"]  = ledgercode;
                        newrow["Ledger (Dr)"] = ledger;
                        newrow["C WHCODE"]    = branch["whcode"].ToString();
                        newrow["Series"]      = branch["receiptseries"].ToString();
                        newrow["Amount"]      = branch["amount"].ToString();
                        string rcptdate = branch["doe"].ToString();
                        newrow["Narration"] = branch["remarks"].ToString() + " vide Receipt No " + branch["sno"].ToString() + ",Receipt Date " + rcptdate + ",Emp Name " + Session["EmpName"].ToString();
                        dtReport.Rows.Add(newrow);
                        i++;
                    }
                }
            }
            grdReports.DataSource = dtReport;
            grdReports.DataBind();
            Session["xportdata"] = dtReport;
            cmd = new SqlCommand("SELECT collections.sno, subaccount_collection.sno AS CSCSNO, collections.accountno, collections.remarks, collections.receiptdate, CONVERT(VARCHAR(10), collections.receiptdate, 103) AS doe, headofaccounts_master.accountname,headofaccounts_master.accountcode, collections.branch, collections.sapimport, subaccount_collection.headofaccount, subaccount_collection.amount, branchmaster.whcode, branchmaster.receiptseries FROM  collections INNER JOIN subaccount_collection ON collections.sno = subaccount_collection.collectionrefno INNER JOIN headofaccounts_master ON subaccount_collection.headofaccount = headofaccounts_master.sno INNER JOIN branchmaster ON collections.subbranch = branchmaster.branchid WHERE (collections.receiptdate BETWEEN @d1 AND @d2) AND (collections.accountno = @accountno) AND (collections.sapimport = '2')");
            cmd.Parameters.Add("@accountno", ddlaccountno.SelectedValue);
            cmd.Parameters.Add("@d1", GetLowDate(fromdate));
            cmd.Parameters.Add("@d2", GetHighDate(todate));
            DataTable dtsalessubcollection = vdm.SelectQuery(cmd).Tables[0];
            int       j = 1;
            foreach (DataRow branch in dtsalessubcollection.Rows)
            {
                string amount  = branch["amount"].ToString();
                string actcode = "";
                double num;
                string accode = branch["accountcode"].ToString();

                sqlcmd = new SqlCommand("SELECT * FROM EMROJDTP WHERE AcctCode=@actcode AND Debit=@Debit AND RefDate=@doe");
                sqlcmd.Parameters.Add("@doe", GetLowDate(fromdate));
                sqlcmd.Parameters.Add("@Debit", amount);
                sqlcmd.Parameters.Add("@actcode", ledgercode);
                DataTable dtJournelexist = SAPvdm.SelectQuery(sqlcmd).Tables[0];
                if (dtJournelexist.Rows.Count > 0)
                {
                }
                else
                {
                    DataRow  newrow = dtReport.NewRow();
                    string   doe    = branch["receiptdate"].ToString();
                    DateTime dtdoe  = Convert.ToDateTime(doe);
                    newrow["Voucher Date"] = dtdoe.ToString("dd-MMM-yyyy");
                    newrow["Voucher No"]   = "BANK_REC" + branch["CSCSNO"].ToString();
                    newrow["Voucher Type"] = "Bank Receipt Import";
                    newrow["Ledger (Dr)"]  = ledger;
                    if (branch["accountname"].ToString() == "")
                    {
                    }
                    else
                    {
                        //newrow["WH Code"] = WHcode;
                        //newrow["Credit Code"] = ledgercode;
                        newrow["C WHCODE"]    = branch["whcode"].ToString();
                        newrow["WH Code"]     = WHcode;
                        newrow["Credit Code"] = branch["accountcode"].ToString();
                        newrow["Ledger (Cr)"] = branch["accountname"].ToString();
                        newrow["Debit Code"]  = ledgercode;
                        newrow["Ledger (Dr)"] = ledger;
                        newrow["Amount"]      = branch["amount"].ToString();
                        string rcptdate = branch["doe"].ToString();
                        newrow["Narration"] = branch["remarks"].ToString() + " vide Receipt No " + branch["sno"].ToString() + ",Receipt Date " + rcptdate + ",Emp Name " + Session["EmpName"].ToString();
                        newrow["Series"]    = branch["receiptseries"].ToString();;
                        dtReport.Rows.Add(newrow);
                        j++;
                    }
                }
            }
            grdReports.DataSource = dtReport;
            grdReports.DataBind();
            Session["xportdata"] = dtReport;
        }
        catch (Exception ex)
        {
            pnlHide.Visible = false;
            lbl_msg.Text    = ex.Message;
        }
    }
 protected void BtnSave_Click(object sender, EventArgs e)
 {
     try
     {
         vdm = new VehicleDBMgr();
         DateTime    CreateDate    = VehicleDBMgr.GetTime(vdm.conn);
         SAPdbmanger SAPvdm        = new SAPdbmanger();
         DateTime    fromdate      = DateTime.Now;
         DataTable   dt            = (DataTable)Session["xportdata"];
         string[]    dateFromstrig = txtfromdate.Text.Split(' ');
         if (dateFromstrig.Length > 1)
         {
             if (dateFromstrig[0].Split('-').Length > 0)
             {
                 string[] dates = dateFromstrig[0].Split('-');
                 string[] times = dateFromstrig[1].Split(':');
                 fromdate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0);
             }
         }
         DateTime ServerDateCurrentdate = VehicleDBMgr.GetTime(vdm.conn);
         fromdate = fromdate.AddDays(1);
         if (dt.Rows.Count > 0)
         {
             DateTime doe = DateTime.Now;
             int      i   = 1;
             foreach (DataRow dr in dt.Rows)
             {
                 string ocrcode2 = "";
                 sqlcmd = new SqlCommand("SELECT PostingDate,DocDate FROM EMROIGN WHERE DocDate BETWEEN @d1 and @d2 AND ReferenceNo=@rno AND ItemCode=@ItemCode AND ItemName=@ItemName and WhsCode=@WhsCode");
                 sqlcmd.Parameters.Add("@d1", GetLowDate(fromdate));
                 sqlcmd.Parameters.Add("@d2", GetHighDate(fromdate));
                 sqlcmd.Parameters.Add("@rno", dr["RefNo"].ToString());
                 sqlcmd.Parameters.Add("@ItemCode", dr["ItemCode"].ToString());
                 sqlcmd.Parameters.Add("@ItemName", dr["ItemName"].ToString());
                 sqlcmd.Parameters.Add("@WhsCode", dr["WhsCode"].ToString());
                 DataTable dtSAPproduction = SAPvdm.SelectQuery(sqlcmd).Tables[0];
                 if (dtSAPproduction.Rows.Count > 0)
                 {
                     lblmsg.Text = "This date data already Saved";
                 }
                 else
                 {
                     sqlcmd = new SqlCommand("Insert into EMROIGN (CreateDate,PostingDate,DocDate,ReferenceNo,ItemCode,ItemName,Quantity,WhsCode,Price,OcrCode,Remarks,B1Upload,Processed,Series,OcrCode2) values (@CreateDate,@PostingDate,@DocDate,@ReferenceNo,@ItemCode,@ItemName,@Quantity,@WhsCode,@Price,@OcrCode,@Remarks,@B1Upload,@Processed,@Series,@OcrCode2)");
                     sqlcmd.Parameters.Add("@CreateDate", ServerDateCurrentdate);
                     sqlcmd.Parameters.Add("@PostingDate", fromdate);
                     sqlcmd.Parameters.Add("@DocDate", fromdate);
                     sqlcmd.Parameters.Add("@ReferenceNo", dr["RefNo"].ToString());
                     sqlcmd.Parameters.Add("@ItemCode", dr["ItemCode"].ToString());
                     sqlcmd.Parameters.Add("@ItemName", dr["ItemName"].ToString());
                     sqlcmd.Parameters.Add("@Quantity", dr["Production Quantity"].ToString());
                     sqlcmd.Parameters.Add("@WhsCode", dr["WhsCode"].ToString());
                     sqlcmd.Parameters.Add("@Price", dr["Price"].ToString());
                     sqlcmd.Parameters.Add("@OcrCode", dr["WhsCode"].ToString());
                     sqlcmd.Parameters.Add("@Remarks", dr["Remarks"].ToString());
                     sqlcmd.Parameters.Add("@Series", "19");
                     sqlcmd.Parameters.Add("@OcrCode2", dr["OcrCode2"].ToString());
                     string B1Upload  = "N";
                     string Processed = "N";
                     sqlcmd.Parameters.Add("@B1Upload", B1Upload);
                     sqlcmd.Parameters.Add("@Processed", Processed);
                     SAPvdm.insert(sqlcmd);
                 }
             }
             pnlHide.Visible = false;
             DataTable dtempty = new DataTable();
             grdReports.DataSource = dtempty;
             grdReports.DataBind();
             lblmsg.Text = "Successfully Saved";
         }
     }
     catch (Exception ex)
     {
         lblmsg.Text = ex.Message;
     }
 }
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        try
        {
            vdm = new VehicleDBMgr();
            DateTime    CreateDate    = VehicleDBMgr.GetTime(vdm.conn);
            SAPdbmanger SAPvdm        = new SAPdbmanger();
            DateTime    fromdate      = DateTime.Now;
            DataTable   dt            = (DataTable)Session["xportdata"];
            string[]    dateFromstrig = txtFromdate.Text.Split(' ');
            if (dateFromstrig.Length > 1)
            {
                if (dateFromstrig[0].Split('-').Length > 0)
                {
                    string[] dates = dateFromstrig[0].Split('-');
                    string[] times = dateFromstrig[1].Split(':');
                    fromdate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0);
                }
            }
            foreach (GridViewRow row in grdReports.Rows)
            {
                //string PaymentMode = "CASH";
                //string B1Upload = "N";
                //string Processed = "N";
                if (row.RowType == DataControlRowType.DataRow)
                {
                    CheckBox chkRow = (row.Cells[0].FindControl("chkRow") as CheckBox);
                    if (chkRow.Checked)
                    {
                        string VoucherDate  = row.Cells[1].Text;
                        string VoucherNo    = row.Cells[2].Text;
                        string VoucherType  = row.Cells[3].Text;
                        string whcode       = row.Cells[4].Text;
                        string debitcode    = row.Cells[5].Text;
                        string debitledger  = row.Cells[6].Text;
                        string creditcode   = row.Cells[8].Text;
                        string AcctCode     = row.Cells[8].Text;
                        string creditledger = row.Cells[9].Text;
                        string Amount       = row.Cells[10].Text;
                        string Narration    = row.Cells[12].Text;
                        string ser          = row.Cells[11].Text;

                        //string AcctCode = dr["Credit Code"].ToString();
                        //string VoucherNo = dr["Voucher No"].ToString();
                        //string vochertype = dr["Voucher Type"].ToString();
                        //string whcode = dr["WH Code"].ToString();
                        //string creditcode = dr["Credit Code"].ToString();
                        //string creditledger = dr["Ledger (Cr)"].ToString();
                        //string debitcode = dr["Debit Code"].ToString();
                        //string debitledger = dr["Ledger (Dr)"].ToString();
                        //string Amount = dr["Amount"].ToString();
                        //string Narration = dr["Narration"].ToString();
                        if (AcctCode == "")
                        {
                        }
                        else
                        {
                            double num;
                            if (double.TryParse(creditcode, out num))
                            {
                                string PaymentMode = "BANK";
                                double amount      = 0;
                                double.TryParse(Amount, out amount);
                                string B1Upload  = "N";
                                string Processed = "N";
                                sqlcmd = new SqlCommand("SELECT CreateDate, RefDate, DocDate, Ref1, Ref2, Ref3 FROM EMROJDTP WHERE (RefDate BETWEEN @d1 AND @d2) AND (Ref1 = @Refno) AND (AcctCode=@AcctCode)");
                                sqlcmd.Parameters.Add("@d1", GetLowDate(fromdate));
                                sqlcmd.Parameters.Add("@d2", GetHighDate(fromdate));
                                sqlcmd.Parameters.Add("@AcctCode", AcctCode);
                                sqlcmd.Parameters.Add("@Refno", VoucherNo);
                                DataTable dtJournelPay = SAPvdm.SelectQuery(sqlcmd).Tables[0];
                                if (dtJournelPay.Rows.Count > 0)
                                {
                                    lbl_msg.Text = "This Receipt Already Saved";
                                }
                                else
                                {
                                    sqlcmd = new SqlCommand("Insert into EMROJDTP (CreateDate, RefDate, DocDate, TransNo, TransCode, AcctCode, AcctName, Debit, Credit, B1Upload, Processed,Ref1,OcrCode,Remarks,series) values (@CreateDate, @RefDate, @DocDate,@TransNo,@TransCode, @AcctCode, @AcctName, @Debit, @Credit, @B1Upload, @Processed,@Ref1,@OcrCode,@Remarks,@series)");
                                    sqlcmd.Parameters.Add("@CreateDate", CreateDate);
                                    sqlcmd.Parameters.Add("@RefDate", GetLowDate(fromdate));
                                    sqlcmd.Parameters.Add("@docdate", GetLowDate(fromdate));
                                    sqlcmd.Parameters.Add("@Ref1", VoucherNo);
                                    string TransCode = "T1";
                                    sqlcmd.Parameters.Add("@TransNo", VoucherNo);
                                    sqlcmd.Parameters.Add("@TransCode", TransCode);
                                    sqlcmd.Parameters.Add("@AcctCode", debitcode);
                                    sqlcmd.Parameters.Add("@AcctName", debitledger);
                                    double.TryParse(Amount, out amount);
                                    sqlcmd.Parameters.Add("@Debit", amount);
                                    string Creditamount = "0";
                                    sqlcmd.Parameters.Add("@Credit", Creditamount);
                                    sqlcmd.Parameters.Add("@B1Upload", B1Upload);
                                    sqlcmd.Parameters.Add("@Processed", Processed);
                                    sqlcmd.Parameters.Add("@OcrCode", whcode);
                                    sqlcmd.Parameters.Add("@Remarks", Narration);
                                    string series = "134";
                                    sqlcmd.Parameters.Add("@series", series);
                                    SAPvdm.insert(sqlcmd);

                                    sqlcmd = new SqlCommand("Insert into EMROJDTP (CreateDate, RefDate, DocDate, TransNo,TransCode, AcctCode, AcctName, Debit, Credit, B1Upload, Processed,Ref1,OcrCode,Remarks,series) values (@CreateDate, @RefDate, @DocDate,@TransNo,@TransCode, @AcctCode, @AcctName, @Debit, @Credit, @B1Upload, @Processed,@Ref1,@OcrCode,@Remarks,@series)");
                                    sqlcmd.Parameters.Add("@CreateDate", CreateDate);
                                    sqlcmd.Parameters.Add("@RefDate", GetLowDate(fromdate));
                                    sqlcmd.Parameters.Add("@docdate", GetLowDate(fromdate));
                                    sqlcmd.Parameters.Add("@Ref1", VoucherNo);
                                    sqlcmd.Parameters.Add("@TransNo", VoucherNo);
                                    sqlcmd.Parameters.Add("@TransCode", TransCode);
                                    sqlcmd.Parameters.Add("@AcctCode", creditcode);
                                    sqlcmd.Parameters.Add("@AcctName", creditledger);
                                    string Debitamount = "0";
                                    sqlcmd.Parameters.Add("@Debit", Debitamount);
                                    sqlcmd.Parameters.Add("@Credit", amount);
                                    sqlcmd.Parameters.Add("@B1Upload", B1Upload);
                                    sqlcmd.Parameters.Add("@Processed", Processed);
                                    sqlcmd.Parameters.Add("@OcrCode", whcode);
                                    sqlcmd.Parameters.Add("@Remarks", Narration);
                                    sqlcmd.Parameters.Add("@series", series);
                                    SAPvdm.insert(sqlcmd);
                                }
                            }
                            else
                            {
                                sqlcmd = new SqlCommand("SELECT CreateDate, PaymentDate, DOE FROM EMRORCT WHERE (PaymentDate BETWEEN @d1 AND @d2) AND (ReferenceNo = @TNo) AND (CardCode=@CardCode)");
                                sqlcmd.Parameters.Add("@d1", GetLowDate(fromdate));
                                sqlcmd.Parameters.Add("@d2", GetHighDate(fromdate));
                                sqlcmd.Parameters.Add("@TNo", VoucherNo);
                                sqlcmd.Parameters.Add("@CardCode", creditcode);
                                DataTable dtovpm = SAPvdm.SelectQuery(sqlcmd).Tables[0];
                                if (dtovpm.Rows.Count > 0)
                                {
                                    lbl_msg.Text = "This Receipt Already Saved";
                                }
                                else
                                {
                                    sqlcmd = new SqlCommand("INSERT INTO EMRORCT(CreateDate, PaymentDate, DOE, ReferenceNo, CardCode, AcctNo, Remarks, PaymentMode, PaymentSum, OcrCode, B1Upload, Processed, Series) values (@CreateDate, @RefDate, @DocDate, @TransNo, @CardCode, @AcctCode, @Remarks, @PaymentMode, @PaymentSum, @OcrCode, @B1Upload, @Processed, @Series)");
                                    sqlcmd.Parameters.Add("@CreateDate", CreateDate);
                                    sqlcmd.Parameters.Add("@RefDate", GetLowDate(fromdate));
                                    sqlcmd.Parameters.Add("@docdate", GetLowDate(fromdate));
                                    sqlcmd.Parameters.Add("@VoucherNo", VoucherNo);
                                    sqlcmd.Parameters.Add("@TransNo", VoucherNo);
                                    sqlcmd.Parameters.Add("@OcrCode", whcode);
                                    sqlcmd.Parameters.Add("@CardCode", creditcode);
                                    sqlcmd.Parameters.Add("@AcctCode", debitcode);
                                    sqlcmd.Parameters.Add("@AcctName", creditledger);
                                    sqlcmd.Parameters.Add("@Series", ser);
                                    sqlcmd.Parameters.Add("@Remarks", Narration);
                                    sqlcmd.Parameters.Add("@PaymentMode", "BANK");
                                    sqlcmd.Parameters.Add("@PaymentSum", Amount);
                                    string B1Upload  = "N";
                                    string Processed = "N";
                                    sqlcmd.Parameters.Add("@B1Upload", B1Upload);
                                    sqlcmd.Parameters.Add("@Processed", Processed);
                                    SAPvdm.insert(sqlcmd);
                                }
                            }
                        }
                    }
                }
            }
            pnlHide.Visible = false;
            DataTable dtempty = new DataTable();
            grdReports.DataSource = dtempty;
            grdReports.DataBind();
            if (lbl_msg.Text == "")
            {
                lbl_msg.Text = "SuccessFully Saved";
            }
        }
        catch (Exception ex)
        {
            lbl_msg.Text = ex.ToString();
        }
    }
Beispiel #4
0
 protected void btn_save_click(object sender, EventArgs e)
 {
     try
     {
         vdm = new SalesDBManager();
         DateTime    CreateDate    = SalesDBManager.GetTime(vdm.conn);
         SAPdbmanger SAPvdm        = new SAPdbmanger();
         DateTime    fromdate      = DateTime.Now;
         DataTable   dt            = (DataTable)Session["xportdata"];
         string[]    dateFromstrig = dtp_FromDate.Text.Split(' ');
         if (dateFromstrig.Length > 1)
         {
             if (dateFromstrig[0].Split('-').Length > 0)
             {
                 string[] dates = dateFromstrig[0].Split('-');
                 string[] times = dateFromstrig[1].Split(':');
                 fromdate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0);
             }
         }
         foreach (DataRow dr in dt.Rows)
         {
             string itemcode = dr["ITEMCODE"].ToString();
             string cardcode = dr["CARD CODE"].ToString();
             if (itemcode == "")
             {
             }
             else if (cardcode == "")
             {
             }
             else
             {
                 cmd = new SqlCommand("SELECT * FROM EMROPOR WHERE (TaxDate BETWEEN @d1 AND @d2) AND (ReferenceNo = @ReferenceNo) AND (ItemCode = @ItemCode) AND (WhsCode = @WhsCode)");
                 cmd.Parameters.Add("@d1", GetLowDate(fromdate));
                 cmd.Parameters.Add("@d2", GetHighDate(fromdate));
                 cmd.Parameters.Add("@ReferenceNo", dr["REFERENCE NO"].ToString());
                 cmd.Parameters.Add("@WhsCode", dr["WARE HOUSE CODE"].ToString());
                 cmd.Parameters.Add("@ItemCode", dr["ITEMCODE"].ToString());
                 DataTable dtPCH = SAPvdm.SelectQuery(cmd).Tables[0];
                 if (dtPCH.Rows.Count > 0)
                 {
                 }
                 else
                 {
                     cmd = new SqlCommand("insert into EMROPOR (CreateDate, CardCode, CardName, TaxDate, DocDate, DocDueDate, DiscPercent, ReferenceNo, ItemCode, Dscription, WhsCode, Quantity, Price, OcrCode, TaxCode, PURCHASETYPE, B1Upload, Processed,remarks,VAT_Percent) values (@CreateDate, @CardCode, @CardName, @TaxDate, @DocDate, @DocDueDate, @DiscPercent, @ReferenceNo, @ItemCode, @Dscription, @WhsCode, @Quantity, @Price, @OcrCode, @TaxCode, @purchasetype, @B1Upload, @Processed,@remarks,@TAXPER)");
                     cmd.Parameters.Add("@CreateDate", CreateDate);
                     cmd.Parameters.Add("@CardCode", dr["CARD CODE"].ToString());
                     cmd.Parameters.Add("@CardName", dr["CARD NAME"].ToString());
                     cmd.Parameters.Add("@TaxDate", fromdate);
                     cmd.Parameters.Add("@DocDate", fromdate);
                     cmd.Parameters.Add("@DocDueDate", fromdate);
                     cmd.Parameters.Add("@DiscPercent", dr["DISCOUNT %"].ToString());
                     cmd.Parameters.Add("@ReferenceNo", dr["REFERENCE NO"].ToString());
                     cmd.Parameters.Add("@ItemCode", dr["ITEMCODE"].ToString());
                     cmd.Parameters.Add("@Dscription", dr["DESCRIPTION"].ToString());
                     cmd.Parameters.Add("@WhsCode", dr["WARE HOUSE CODE"].ToString());
                     double qty = 0;
                     double.TryParse(dr["QUANTITY"].ToString(), out qty);
                     cmd.Parameters.Add("@Quantity", qty);
                     double price = 0;
                     double.TryParse(dr["PRICE"].ToString(), out price);
                     cmd.Parameters.Add("@Price", price);
                     cmd.Parameters.Add("@OcrCode", dr["WARE HOUSE CODE"].ToString());
                     cmd.Parameters.Add("@TaxCode", dr["TAXCODE"].ToString());
                     cmd.Parameters.Add("@TAXPER", dr["TAX%"].ToString());
                     string B1Upload     = "N";
                     string Processed    = "N";
                     string purchasetype = "93";
                     cmd.Parameters.Add("@purchasetype", purchasetype);
                     cmd.Parameters.Add("@B1Upload", B1Upload);
                     cmd.Parameters.Add("@Processed", Processed);
                     cmd.Parameters.Add("@remarks", dr["Narration"].ToString());
                     if (qty == 0.0)
                     {
                     }
                     else
                     {
                         SAPvdm.insert(cmd);
                     }
                 }
             }
         }
         hidepanel.Visible = false;
         lblmsg.Text       = "Saved successfully";
         DataTable dtempty = new DataTable();
         grdReports.DataSource = dtempty;
         grdReports.DataBind();
     }
     catch (Exception ex)
     {
         lblmsg.Text       = ex.Message;
         hidepanel.Visible = false;
     }
 }
Beispiel #5
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        try
        {
            vdm = new VehicleDBMgr();
            DateTime    CreateDate    = VehicleDBMgr.GetTime(vdm.conn);
            SAPdbmanger SAPvdm        = new SAPdbmanger();
            DateTime    fromdate      = DateTime.Now;
            DataTable   dt            = (DataTable)Session["xportdata"];
            string[]    dateFromstrig = txtFromdate.Text.Split(' ');
            if (dateFromstrig.Length > 1)
            {
                if (dateFromstrig[0].Split('-').Length > 0)
                {
                    string[] dates = dateFromstrig[0].Split('-');
                    string[] times = dateFromstrig[1].Split(':');
                    fromdate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0);
                }
            }
            DataTable CustomerCodes = new DataTable();
            CustomerCodes.Columns.Add("Ledger Type");
            CustomerCodes.Columns.Add("Customer Code");
            CustomerCodes.Columns.Add("Customer Name");
            CustomerCodes.Columns.Add("Invoice Date");
            CustomerCodes.Columns.Add("Invoce No");
            CustomerCodes.Columns.Add("HSN CODE");
            CustomerCodes.Columns.Add("Item Code");
            CustomerCodes.Columns.Add("Item Name");
            CustomerCodes.Columns.Add("Qty");
            CustomerCodes.Columns.Add("Rate");
            CustomerCodes.Columns.Add("Tax Code");
            CustomerCodes.Columns.Add("Sales Type");
            CustomerCodes.Columns.Add("TAX%");
            CustomerCodes.Columns.Add("Taxable Value");
            CustomerCodes.Columns.Add("Rounding Off");
            CustomerCodes.Columns.Add("WH Code");
            CustomerCodes.Columns.Add("Inv Value");
            CustomerCodes.Columns.Add("Net Value");
            CustomerCodes.Columns.Add("Narration");


            cmd = new MySqlCommand("SELECT sno, BranchName, whcode, ladger_dr_code, tax, ntax, ledger_jv_code FROM branchdata WHERE (sno = @BranchID)");
            cmd.Parameters.AddWithValue("@BranchID", ddlSalesOffice.SelectedValue);
            DataTable dtwhscode = vdm.SelectQuery(cmd).Tables[0];
            ////sqlcmd = new SqlCommand("SELECT CreateDate, CardCode, CardName, TaxDate, DocDate, DocDueDate, DiscPercent, ReferenceNo FROM  EMRORDR WHERE (TaxDate BETWEEN @d1 AND @d2)  AND (WhsCode = @WhsCode) AND CardCode=@CardCode");
            ////sqlcmd.Parameters.Add("@d1", GetLowDate(fromdate));
            ////sqlcmd.Parameters.Add("@d2", GetHighDate(fromdate));
            ////sqlcmd.Parameters.Add("@WhsCode", dtwhscode.Rows[0]["whcode"].ToString());
            ////sqlcmd.Parameters.Add("@CardCode", dtwhscode.Rows[0]["whcode"].ToString());
            DataTable dtOrder = SAPvdm.SelectQuery(sqlcmd).Tables[0];
            if (dtOrder.Rows.Count > 0)
            {
                lblmsg.Text = "This Transaction already saved";
            }
            else
            {
                foreach (DataRow dr in dt.Rows)
                {
                    sqlcmd = new SqlCommand("SELECT CreateDate, CardCode, CardName, TaxDate, DocDate, DocDueDate, DiscPercent, ReferenceNo FROM  EMRORDR WHERE (TaxDate BETWEEN @d1 AND @d2)  AND (WhsCode = @WhsCode) AND CardCode=@CardCode");
                    sqlcmd.Parameters.Add("@d1", GetLowDate(fromdate));
                    sqlcmd.Parameters.Add("@d2", GetHighDate(fromdate));
                    sqlcmd.Parameters.Add("@WhsCode", dtwhscode.Rows[0]["whcode"].ToString());
                    sqlcmd.Parameters.Add("@CardCode", dtwhscode.Rows[0]["whcode"].ToString());


                    string Customercode = dr["Customer Code"].ToString();
                    string whccode      = dr["WH Code"].ToString();
                    if (Customercode == "CHN01")
                    {
                    }
                    if (Customercode == "")
                    {
                        DataRow newrow = CustomerCodes.NewRow();
                        newrow["Ledger Type"]   = dr["Ledger Type"].ToString();
                        newrow["Customer Name"] = dr["Customer Name"].ToString();
                        newrow["Customer Code"] = dr["Customer Code"].ToString();
                        newrow["Invoice Date"]  = dr["Invoice Date"].ToString();
                        newrow["Invoce No"]     = dr["Invoce No"].ToString();
                        newrow["HSN CODE"]      = dr["HSN CODE"].ToString();
                        newrow["Item Code"]     = dr["Item Code"].ToString();
                        newrow["Item Name"]     = dr["Item Name"].ToString();
                        newrow["Qty"]           = dr["Qty"].ToString();
                        newrow["Rate"]          = dr["Rate"].ToString();
                        newrow["Tax Code"]      = dr["Tax Code"].ToString();
                        newrow["Sales Type"]    = dr["Sales Type"].ToString();
                        newrow["TAX%"]          = dr["TAX%"].ToString();
                        newrow["Taxable Value"] = dr["Taxable Value"].ToString();
                        newrow["WH Code"]       = dr["WH Code"].ToString();
                        newrow["Net Value"]     = dr["Net Value"].ToString();
                        newrow["Narration"]     = dr["Narration"].ToString();
                        CustomerCodes.Rows.Add(newrow);
                    }
                    else
                    {
                        if (Customercode.Length >= 8)
                        {
                            string Itemcode = dr["Item Code"].ToString();
                            if (Itemcode == "")
                            {
                            }
                            else
                            {
                                //sqlcmd = new SqlCommand("SELECT CreateDate, CardCode, CardName, TaxDate, DocDate, DocDueDate, DiscPercent, ReferenceNo FROM  EMRORDR WHERE (TaxDate BETWEEN @d1 AND @d2) AND (ReferenceNo = @ReferenceNo) AND (itemcode=@itemcode) AND (WhsCode = @WhsCode)");
                                //sqlcmd.Parameters.Add("@d1", GetLowDate(fromdate));
                                //sqlcmd.Parameters.Add("@d2", GetHighDate(fromdate));
                                //sqlcmd.Parameters.Add("@ReferenceNo", dr["Invoce No"].ToString());
                                //sqlcmd.Parameters.Add("@WhsCode", whccode);
                                //sqlcmd.Parameters.Add("@itemcode", dr["Item Code"].ToString());
                                //DataTable dtSalesOrder = SAPvdm.SelectQuery(sqlcmd).Tables[0];
                                //if (dtSalesOrder.Rows.Count > 0)
                                //{
                                //}
                                //else
                                //{
                                sqlcmd = new SqlCommand("Insert into EMRORDR (cardcode,cardname,TaxDate, DocDate, DocDueDate,dscription,itemcode,quantity,price,whscode,vat_percent,taxamount,ReferenceNo,TaxCode,B1Upload,Processed,CreateDate,REMARKS,SALETYPE) values(@cardcode,@cardname,@TaxDate,@DocDate,@DocDueDate,@dscription,@itemcode,@quantity,@price,@whscode,@vat_percent,@taxamount,@ReferenceNo,@TaxCode,@B1Upload,@Processed,@CreateDate,@REMARKS,@SALETYPE)");
                                sqlcmd.Parameters.Add("@cardcode", dr["Customer Code"].ToString());
                                sqlcmd.Parameters.Add("@cardname", dr["Customer Name"].ToString());
                                sqlcmd.Parameters.Add("@TaxDate", GetLowDate(fromdate));
                                sqlcmd.Parameters.Add("@docdate", GetLowDate(fromdate));
                                sqlcmd.Parameters.Add("@DocDueDate", GetLowDate(fromdate));
                                sqlcmd.Parameters.Add("@dscription", dr["Item Name"].ToString());
                                sqlcmd.Parameters.Add("@itemcode", dr["Item Code"].ToString());
                                sqlcmd.Parameters.Add("@quantity", dr["Qty"].ToString());
                                sqlcmd.Parameters.Add("@price", dr["Rate"].ToString());
                                sqlcmd.Parameters.Add("@whscode", whccode);
                                sqlcmd.Parameters.Add("@vat_percent", dr["TAX%"].ToString());
                                sqlcmd.Parameters.Add("@taxamount", dr["Taxable Value"].ToString());
                                sqlcmd.Parameters.Add("@ReferenceNo", dr["Invoce No"].ToString());
                                string TaxCode   = dr["Tax Code"].ToString();
                                string B1Upload  = "N";
                                string Processed = "N";
                                sqlcmd.Parameters.Add("@TaxCode", TaxCode);
                                sqlcmd.Parameters.Add("@B1Upload", B1Upload);
                                sqlcmd.Parameters.Add("@Processed", Processed);
                                sqlcmd.Parameters.Add("@CreateDate", CreateDate);
                                sqlcmd.Parameters.Add("@REMARKS", dr["Narration"].ToString());
                                string salestype = dr["Sales Type"].ToString();
                                sqlcmd.Parameters.Add("@SALETYPE", salestype);
                                //SAPvdm.insert(sqlcmd);
                            }
                            //}
                        }
                        else
                        {
                            DataRow newrow1 = CustomerCodes.NewRow();
                            newrow1["Ledger Type"]   = dr["Ledger Type"].ToString();
                            newrow1["Customer Name"] = dr["Customer Name"].ToString();
                            newrow1["Customer Code"] = dr["Customer Code"].ToString();
                            newrow1["Invoice Date"]  = dr["Invoice Date"].ToString();
                            newrow1["Invoce No"]     = dr["Invoce No"].ToString();
                            newrow1["HSN CODE"]      = dr["HSN CODE"].ToString();
                            newrow1["Item Code"]     = dr["Item Code"].ToString();
                            newrow1["Item Name"]     = dr["Item Name"].ToString();
                            newrow1["Qty"]           = dr["Qty"].ToString();
                            newrow1["Rate"]          = dr["Rate"].ToString();
                            newrow1["Tax Code"]      = dr["Tax Code"].ToString();
                            newrow1["Sales Type"]    = dr["Sales Type"].ToString();
                            newrow1["TAX%"]          = dr["TAX%"].ToString();
                            newrow1["Taxable Value"] = dr["Taxable Value"].ToString();
                            newrow1["WH Code"]       = dr["WH Code"].ToString();
                            newrow1["Net Value"]     = dr["Net Value"].ToString();
                            newrow1["Narration"]     = dr["Narration"].ToString();
                            CustomerCodes.Rows.Add(newrow1);
                        }
                    }
                }
                //pnlHide.Visible = false;
                DataTable dtempty = new DataTable();
                grdReports.DataSource = dtempty;
                grdReports.DataBind();
                grdReports1.DataSource = CustomerCodes;
                grdReports1.DataBind();
                lblmsg.Text = "Successfully Saved";
            }
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.ToString();
        }
    }
Beispiel #6
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        try
        {
            vdm = new SalesDBManager();
            DateTime    CreateDate    = SalesDBManager.GetTime(vdm.conn);
            SAPdbmanger SAPvdm        = new SAPdbmanger();
            DateTime    fromdate      = DateTime.Now;
            DataTable   dt            = (DataTable)Session["xportdata"];
            string[]    dateFromstrig = dtp_FromDate.Text.Split(' ');
            if (dateFromstrig.Length > 1)
            {
                if (dateFromstrig[0].Split('-').Length > 0)
                {
                    string[] dates = dateFromstrig[0].Split('-');
                    string[] times = dateFromstrig[1].Split(':');
                    fromdate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0);
                }
            }
            foreach (DataRow dr in dt.Rows)
            {
                if (ddltype.SelectedItem.Value == "2")
                {
                    string AcctCode = dr["Ledger Code"].ToString();
                    string whCode   = dr["WH Code"].ToString();
                    if (AcctCode == "" && whCode == "")
                    {
                    }
                    else
                    {
                        sqlcmd = new SqlCommand("SELECT CreateDate, RefDate, DocDate, Ref1, Ref2, Ref3, TransNo, AcctCode FROM EMROJDT WHERE (RefDate BETWEEN @d1 AND @d2) AND (TransNo = @TransNo) AND (Ref1=@Ref1) AND (OcrCode = @OcrCode) AND (AcctCode=@AcCode)");
                        sqlcmd.Parameters.Add("@d1", GetLowDate(fromdate));
                        sqlcmd.Parameters.Add("@d2", GetHighDate(fromdate));
                        sqlcmd.Parameters.Add("@TransNo", dr["JV No"].ToString());
                        sqlcmd.Parameters.Add("@OcrCode", dr["WH Code"].ToString());
                        sqlcmd.Parameters.Add("@Ref1", dr["Item Code"].ToString());
                        sqlcmd.Parameters.Add("@AcCode", dr["Ledger Code"].ToString());
                        DataTable dtJournelPay = SAPvdm.SelectQuery(sqlcmd).Tables[0];
                        if (dtJournelPay.Rows.Count > 0)
                        {
                        }
                        else
                        {
                            sqlcmd = new SqlCommand("Insert into EMROJDT (CreateDate, RefDate, DocDate, TransNo, AcctCode, AcctName, Debit, Credit, B1Upload, Processed,Ref1,OcrCode,OcrCode2,series) values (@CreateDate, @RefDate, @DocDate,@TransNo, @AcctCode, @AcctName, @Debit, @Credit, @B1Upload, @Processed,@Ref1,@OcrCode,@OcrCode2,@series)");
                            sqlcmd.Parameters.Add("@CreateDate", GetLowDate(fromdate));
                            sqlcmd.Parameters.Add("@RefDate", GetLowDate(fromdate));
                            sqlcmd.Parameters.Add("@docdate", GetLowDate(fromdate));
                            sqlcmd.Parameters.Add("@Ref1", dr["Item Code"].ToString());
                            sqlcmd.Parameters.Add("@TransNo", dr["JV No"].ToString());
                            sqlcmd.Parameters.Add("@AcctCode", dr["Ledger Code"].ToString());
                            sqlcmd.Parameters.Add("@AcctName", dr["Ledger Name"].ToString());
                            double amount = 0;
                            double.TryParse(dr["Total Amount"].ToString(), out amount);
                            double Debit = 0;
                            sqlcmd.Parameters.Add("@Debit", Debit);
                            sqlcmd.Parameters.Add("@Credit", amount);
                            string B1Upload  = "N";
                            string Processed = "N";
                            sqlcmd.Parameters.Add("@B1Upload", B1Upload);
                            sqlcmd.Parameters.Add("@Processed", Processed);
                            sqlcmd.Parameters.Add("@OcrCode", dr["WH Code"].ToString());
                            sqlcmd.Parameters.Add("@OcrCode2", dr["Category Code"].ToString());
                            string series = "230";
                            sqlcmd.Parameters.Add("@series", series);
                            SAPvdm.insert(sqlcmd);


                            sqlcmd = new SqlCommand("Insert into EMROJDT (CreateDate, RefDate, DocDate, TransNo, AcctCode, AcctName, Debit, Credit, B1Upload, Processed,Ref1,OcrCode,OcrCode2,series) values (@CreateDate, @RefDate, @DocDate,@TransNo, @AcctCode, @AcctName, @Debit, @Credit, @B1Upload, @Processed,@Ref1,@OcrCode,@OcrCode2,@series)");
                            sqlcmd.Parameters.Add("@CreateDate", GetLowDate(fromdate));
                            sqlcmd.Parameters.Add("@RefDate", GetLowDate(fromdate));
                            sqlcmd.Parameters.Add("@docdate", GetLowDate(fromdate));
                            sqlcmd.Parameters.Add("@Ref1", dr["Item Code"].ToString());
                            sqlcmd.Parameters.Add("@TransNo", dr["JV No"].ToString());
                            sqlcmd.Parameters.Add("@AcctCode", dr["Ledger Code"].ToString());
                            sqlcmd.Parameters.Add("@AcctName", dr["Ledger Name"].ToString());
                            double tamount = 0;
                            double.TryParse(dr["Total Amount"].ToString(), out tamount);
                            double Credit = 0;
                            sqlcmd.Parameters.Add("@Debit", tamount);
                            sqlcmd.Parameters.Add("@Credit", Credit);
                            sqlcmd.Parameters.Add("@B1Upload", B1Upload);
                            sqlcmd.Parameters.Add("@Processed", Processed);
                            sqlcmd.Parameters.Add("@OcrCode", dr["WH Code"].ToString());
                            sqlcmd.Parameters.Add("@OcrCode2", dr["Category Code"].ToString());
                            sqlcmd.Parameters.Add("@series", series);
                            SAPvdm.insert(sqlcmd);
                        }
                    }
                }
                else
                {
                    double amount = 0;
                    double.TryParse(dr["Total Amount"].ToString(), out amount);
                    string B1Upload  = "N";
                    string Processed = "N";
                    sqlcmd = new SqlCommand("SELECT CreateDate, PostingDate, DocDate, ReferenceNo, ItemCode, ItemName FROM EMROIGE WHERE (PostingDate BETWEEN @d1 AND @d2) AND (ItemCode=@ItemCode) AND (ReferenceNo = @ReferenceNo) AND (WhsCode = @WhsCode)");
                    sqlcmd.Parameters.Add("@d1", GetLowDate(fromdate));
                    sqlcmd.Parameters.Add("@d2", GetHighDate(fromdate));
                    sqlcmd.Parameters.Add("@ReferenceNo", dr["JV No"].ToString());
                    sqlcmd.Parameters.Add("@WhsCode", dr["WH Code"].ToString());
                    sqlcmd.Parameters.Add("@ItemCode", dr["Item Code"].ToString());
                    DataTable dtGoodsIssue = SAPvdm.SelectQuery(sqlcmd).Tables[0];
                    if (dtGoodsIssue.Rows.Count > 0)
                    {
                    }
                    else
                    {
                        sqlcmd = new SqlCommand("Insert into EMROIGE (CreateDate,PostingDate,DocDate,ReferenceNo,ItemCode,ItemName,Price,Quantity,WhsCode,OcrCode,OcrCode2,Remarks,B1Upload,Processed,series) values (@CreateDate,@PostingDate,@DocDate,@ReferenceNo,@ItemCode,@ItemName,@Price,@Quantity,@WhsCode,@OcrCode,@OcrCode2,@Remarks,@B1Upload,@Processed,@series)");
                        sqlcmd.Parameters.Add("@CreateDate", CreateDate);
                        sqlcmd.Parameters.Add("@PostingDate", GetLowDate(fromdate));
                        sqlcmd.Parameters.Add("@DocDate", GetLowDate(fromdate));
                        sqlcmd.Parameters.Add("@ReferenceNo", dr["JV No"].ToString());
                        sqlcmd.Parameters.Add("@ItemCode", dr["Item Code"].ToString());
                        sqlcmd.Parameters.Add("@ItemName", dr["Item Name"].ToString());
                        sqlcmd.Parameters.Add("@Price", amount);
                        sqlcmd.Parameters.Add("@Quantity", dr["Qty"].ToString());
                        sqlcmd.Parameters.Add("@WhsCode", dr["WH Code"].ToString());
                        sqlcmd.Parameters.Add("@OcrCode", dr["WH Code"].ToString());
                        sqlcmd.Parameters.Add("@OcrCode2", dr["Category Code"].ToString());
                        sqlcmd.Parameters.Add("@Remarks", dr["Narration"].ToString());
                        sqlcmd.Parameters.Add("@B1Upload", B1Upload);
                        sqlcmd.Parameters.Add("@Processed", Processed);
                        string series = "240";
                        sqlcmd.Parameters.Add("@series", series);
                        SAPvdm.insert(sqlcmd);
                    }
                    string AcctCode = dr["Ledger Code"].ToString();
                    string whCode   = dr["WH Code"].ToString();
                    if (AcctCode == "" && whCode == "")
                    {
                    }
                    else
                    {
                        sqlcmd = new SqlCommand("SELECT CreateDate, RefDate, DocDate, Ref1, Ref2, Ref3, TransNo, AcctCode FROM EMROJDT WHERE (RefDate BETWEEN @d1 AND @d2) AND (TransNo = @TransNo) AND (Ref1=@Ref1) AND (OcrCode = @OcrCode)");
                        sqlcmd.Parameters.Add("@d1", GetLowDate(fromdate));
                        sqlcmd.Parameters.Add("@d2", GetHighDate(fromdate));
                        sqlcmd.Parameters.Add("@TransNo", dr["JV No"].ToString());
                        sqlcmd.Parameters.Add("@OcrCode", dr["WH Code"].ToString());
                        sqlcmd.Parameters.Add("@Ref1", dr["Item Code"].ToString());
                        DataTable dtJournelPay = SAPvdm.SelectQuery(sqlcmd).Tables[0];
                        if (dtJournelPay.Rows.Count > 0)
                        {
                        }
                        else
                        {
                            sqlcmd = new SqlCommand("Insert into EMROJDT (CreateDate, RefDate, DocDate, TransNo, AcctCode, AcctName, Debit, Credit, B1Upload, Processed,Ref1,OcrCode,OcrCode2,series) values (@CreateDate, @RefDate, @DocDate,@TransNo, @AcctCode, @AcctName, @Debit, @Credit, @B1Upload, @Processed,@Ref1,@OcrCode,@OcrCode2,@series)");
                            sqlcmd.Parameters.Add("@CreateDate", GetLowDate(fromdate));
                            sqlcmd.Parameters.Add("@RefDate", GetLowDate(fromdate));
                            sqlcmd.Parameters.Add("@docdate", GetLowDate(fromdate));
                            sqlcmd.Parameters.Add("@Ref1", dr["Item Code"].ToString());
                            sqlcmd.Parameters.Add("@TransNo", dr["JV No"].ToString());
                            sqlcmd.Parameters.Add("@AcctCode", dr["Ledger Code"].ToString());
                            sqlcmd.Parameters.Add("@AcctName", dr["Ledger Name"].ToString());
                            double camount = 0;
                            double.TryParse(dr["Total Amount"].ToString(), out camount);
                            double Debit = 0;
                            sqlcmd.Parameters.Add("@Debit", Debit);
                            sqlcmd.Parameters.Add("@Credit", camount);
                            string cB1Upload  = "N";
                            string cProcessed = "N";
                            sqlcmd.Parameters.Add("@B1Upload", cB1Upload);
                            sqlcmd.Parameters.Add("@Processed", cProcessed);
                            sqlcmd.Parameters.Add("@OcrCode", dr["WH Code"].ToString());
                            sqlcmd.Parameters.Add("@OcrCode2", dr["Category Code"].ToString());
                            string series = "230";
                            sqlcmd.Parameters.Add("@series", series);
                            SAPvdm.insert(sqlcmd);


                            sqlcmd = new SqlCommand("Insert into EMROJDT (CreateDate, RefDate, DocDate, TransNo, AcctCode, AcctName, Debit, Credit, B1Upload, Processed,Ref1,OcrCode,OcrCode2,series) values (@CreateDate, @RefDate, @DocDate,@TransNo, @AcctCode, @AcctName, @Debit, @Credit, @B1Upload, @Processed,@Ref1,@OcrCode,@OcrCode2,@series)");
                            sqlcmd.Parameters.Add("@CreateDate", GetLowDate(fromdate));
                            sqlcmd.Parameters.Add("@RefDate", GetLowDate(fromdate));
                            sqlcmd.Parameters.Add("@docdate", GetLowDate(fromdate));
                            sqlcmd.Parameters.Add("@Ref1", dr["Item Code"].ToString());
                            sqlcmd.Parameters.Add("@TransNo", dr["JV No"].ToString());
                            sqlcmd.Parameters.Add("@AcctCode", dr["Ledger Code"].ToString());
                            sqlcmd.Parameters.Add("@AcctName", dr["Ledger Name"].ToString());
                            double damount = 0;
                            double.TryParse(dr["Total Amount"].ToString(), out damount);
                            double Credit = 0;
                            sqlcmd.Parameters.Add("@Debit", damount);
                            sqlcmd.Parameters.Add("@Credit", Credit);
                            sqlcmd.Parameters.Add("@B1Upload", B1Upload);
                            sqlcmd.Parameters.Add("@Processed", Processed);
                            sqlcmd.Parameters.Add("@OcrCode", dr["WH Code"].ToString());
                            sqlcmd.Parameters.Add("@OcrCode2", dr["Category Code"].ToString());
                            sqlcmd.Parameters.Add("@series", series);
                            SAPvdm.insert(sqlcmd);
                        }
                    }
                }
            }
            DataTable dtempty = new DataTable();
            grdReports.DataSource = dtempty;
            grdReports.DataBind();
            lblmsg.Text = "Successfully Saved";
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.ToString();
        }
    }
Beispiel #7
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        try
        {
            vdm = new VehicleDBMgr();
            DateTime    CreateDate    = VehicleDBMgr.GetTime(vdm.conn);
            SAPdbmanger SAPvdm        = new SAPdbmanger();
            DateTime    fromdate      = DateTime.Now;
            DataTable   dt            = (DataTable)Session["xportdata"];
            string[]    dateFromstrig = txtFromdate.Text.Split(' ');
            if (dateFromstrig.Length > 1)
            {
                if (dateFromstrig[0].Split('-').Length > 0)
                {
                    string[] dates = dateFromstrig[0].Split('-');
                    string[] times = dateFromstrig[1].Split(':');
                    fromdate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0);
                }
            }
            if (ddlSalesOffice.SelectedValue == "306")
            {
                fromdate = fromdate.AddDays(1);
            }
            else
            {
                fromdate = fromdate;
            }

            //cmd = new MySqlCommand("SELECT sno, BranchName, whcode, ladger_dr_code, tax, ntax, ledger_jv_code FROM branchdata WHERE (sno = @BranchID)");
            //cmd.Parameters.AddWithValue("@BranchID", ddlSalesOffice.SelectedValue);
            //DataTable dtwhscode = vdm.SelectQuery(cmd).Tables[0];
            //sqlcmd = new SqlCommand("SELECT CreateDate, RefDate, DocDate, Ref1, Ref2, Ref3, TransNo, AcctCode FROM EMROJDT WHERE (RefDate BETWEEN @d1 AND @d2) AND (OcrCode = @WhsCode)");
            //sqlcmd.Parameters.Add("@d1", GetLowDate(fromdate));
            //sqlcmd.Parameters.Add("@d2", GetHighDate(fromdate));
            //sqlcmd.Parameters.Add("@WhsCode", dtwhscode.Rows[0]["whcode"].ToString());
            //DataTable dtGI = SAPvdm.SelectQuery(sqlcmd).Tables[0];
            //if (dtGI.Rows.Count > 0)
            //{
            //    lblmsg.Text = "This Transaction already saved";
            //}
            //else
            //{
            DataTable dtJournelPay = new DataTable();
            foreach (DataRow dr in dt.Rows)
            {
                string AcctCode = dr["Ledger Code"].ToString();
                string whCode   = dr["WH Code"].ToString();

                if (AcctCode == "" && whCode == "")
                {
                }
                else
                {
                    sqlcmd = new SqlCommand("SELECT CreateDate, RefDate, DocDate, Ref1, Ref2, Ref3, TransNo, AcctCode FROM EMROJDT WHERE (RefDate BETWEEN @d1 AND @d2) AND (TransNo = @TransNo) AND (Ref1=@Ref1) AND (OcrCode = @OcrCode)");
                    sqlcmd.Parameters.Add("@d1", GetLowDate(fromdate));
                    sqlcmd.Parameters.Add("@d2", GetHighDate(fromdate));
                    sqlcmd.Parameters.Add("@TransNo", dr["JV No"].ToString());
                    sqlcmd.Parameters.Add("@OcrCode", dr["WH Code"].ToString());
                    sqlcmd.Parameters.Add("@Ref1", dr["Item Code"].ToString());
                    dtJournelPay = SAPvdm.SelectQuery(sqlcmd).Tables[0];
                    if (dtJournelPay.Rows.Count > 0)
                    {
                        lblmsg.Text = "This Transaction already saved";
                        break;
                    }
                    else
                    {
                        sqlcmd = new SqlCommand("Insert into EMROJDT (CreateDate, RefDate, DocDate, TransNo, AcctCode, AcctName, Debit, Credit, B1Upload, Processed,Ref1,OcrCode,OcrCode2,series) values (@CreateDate, @RefDate, @DocDate,@TransNo, @AcctCode, @AcctName, @Debit, @Credit, @B1Upload, @Processed,@Ref1,@OcrCode,@OcrCode2,@series)");
                        sqlcmd.Parameters.Add("@CreateDate", GetLowDate(fromdate));
                        sqlcmd.Parameters.Add("@RefDate", GetLowDate(fromdate));
                        sqlcmd.Parameters.Add("@docdate", GetLowDate(fromdate));
                        sqlcmd.Parameters.Add("@Ref1", dr["Item Code"].ToString());
                        sqlcmd.Parameters.Add("@TransNo", dr["JV No"].ToString());
                        sqlcmd.Parameters.Add("@AcctCode", dr["Ledger Code"].ToString());
                        sqlcmd.Parameters.Add("@AcctName", dr["Ledger Name"].ToString());
                        double amount = 0;
                        double.TryParse(dr["Total Amount"].ToString(), out amount);
                        amount = Math.Round(amount, 2);
                        if (amount < 0)
                        {
                            amount = Math.Abs(amount);
                            double Debit = 0;
                            sqlcmd.Parameters.Add("@Debit", Debit);
                            sqlcmd.Parameters.Add("@Credit", amount);
                        }
                        else
                        {
                            amount = Math.Abs(amount);
                            double Credit = 0;
                            sqlcmd.Parameters.Add("@Debit", amount);
                            sqlcmd.Parameters.Add("@Credit", Credit);
                        }
                        string B1Upload  = "N";
                        string Processed = "N";
                        sqlcmd.Parameters.Add("@B1Upload", B1Upload);
                        sqlcmd.Parameters.Add("@Processed", Processed);
                        sqlcmd.Parameters.Add("@OcrCode", dr["WH Code"].ToString());
                        sqlcmd.Parameters.Add("@OcrCode2", dr["Category Code"].ToString());
                        string series = "17";
                        sqlcmd.Parameters.Add("@series", series);
                        if (amount == 0.0)
                        {
                        }
                        else
                        {
                            SAPvdm.insert(sqlcmd);
                        }
                    }
                }
            }
            if (dtJournelPay.Rows.Count > 0)
            {
                pnlHide.Visible = false;
                DataTable dtempty = new DataTable();
                grdReports.DataSource = dtempty;
                grdReports.DataBind();
                lblmsg.Text = "This Transaction already saved";
            }
            else
            {
                pnlHide.Visible = false;
                DataTable dtempty = new DataTable();
                grdReports.DataSource = dtempty;
                grdReports.DataBind();
                lblmsg.Text = "Successfully Saved";
            }
            //}
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.ToString();
        }
    }
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        try
        {
            vdm = new VehicleDBMgr();
            DateTime    CreateDate    = VehicleDBMgr.GetTime(vdm.conn);
            SAPdbmanger SAPvdm        = new SAPdbmanger();
            DateTime    fromdate      = DateTime.Now;
            DataTable   dt            = (DataTable)Session["xportdata"];
            string[]    dateFromstrig = txtFromdate.Text.Split(' ');
            if (dateFromstrig.Length > 1)
            {
                if (dateFromstrig[0].Split('-').Length > 0)
                {
                    string[] dates = dateFromstrig[0].Split('-');
                    string[] times = dateFromstrig[1].Split(':');
                    fromdate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0);
                }
            }

            cmd = new MySqlCommand("SELECT sno, BranchName, whcode, ladger_dr_code, tax, ntax, ledger_jv_code FROM branchdata WHERE (sno = @BranchID)");
            cmd.Parameters.AddWithValue("@BranchID", ddlSalesOffice.SelectedValue);
            DataTable dtwhscode = vdm.SelectQuery(cmd).Tables[0];
            sqlcmd = new SqlCommand("SELECT CreateDate, PostingDate, DocDate, CardCode, Cardname FROM  EMRORIN WHERE  (PostingDate BETWEEN @d1 AND @d2) AND (OcrCode = @whscode)");
            sqlcmd.Parameters.Add("@d1", GetLowDate(fromdate));
            sqlcmd.Parameters.Add("@d2", GetHighDate(fromdate));
            sqlcmd.Parameters.Add("@whscode", dtwhscode.Rows[0]["whcode"].ToString());
            DataTable dtGI = SAPvdm.SelectQuery(sqlcmd).Tables[0];
            if (dtGI.Rows.Count > 0)
            {
                lblmsg.Text = "This Transaction already saved";
            }
            else
            {
                foreach (DataRow dr in dt.Rows)
                {
                    string CardCode = dr["Customer Code"].ToString();
                    if (CardCode == "")
                    {
                    }
                    else
                    {
                        sqlcmd = new SqlCommand("SELECT CreateDate, PostingDate, DocDate, CardCode, Cardname , Series FROM EMRORIN WHERE (PostingDate BETWEEN @d1 AND @d2) AND (ReferenceNo = @ReferenceNo) and (CardCode=@CardCode)");
                        sqlcmd.Parameters.Add("@d1", GetLowDate(fromdate));
                        sqlcmd.Parameters.Add("@d2", GetHighDate(fromdate));
                        sqlcmd.Parameters.Add("@ReferenceNo", dr["JV No"].ToString());
                        sqlcmd.Parameters.Add("@CardCode", dr["Customer Code"].ToString());
                        DataTable dtIncentives = SAPvdm.SelectQuery(sqlcmd).Tables[0];
                        if (dtIncentives.Rows.Count > 0)
                        {
                        }
                        else
                        {
                            sqlcmd = new SqlCommand("Insert into EMRORIN (CreateDate,PostingDate,DocDate,CardCode,Cardname,ReferenceNo,Description,AcctCode,Price,TaxCode,LocCode,OcrCode,Remarks,B1Upload,Processed,Series) values (@CreateDate,@PostingDate,@DocDate,@CardCode,@Cardname,@ReferenceNo,@Description,@AcctCode,@Price,@TaxCode,@LocCode,@OcrCode,@Remarks,@B1Upload,@Processed,@Series)");
                            sqlcmd.Parameters.Add("@CreateDate", GetLowDate(fromdate));
                            sqlcmd.Parameters.Add("@PostingDate", GetLowDate(fromdate));
                            sqlcmd.Parameters.Add("@DocDate", GetLowDate(fromdate));
                            sqlcmd.Parameters.Add("@CardCode", dr["Customer Code"].ToString());
                            sqlcmd.Parameters.Add("@Cardname", dr["Customer Name"].ToString());
                            sqlcmd.Parameters.Add("@ReferenceNo", dr["JV No"].ToString());
                            string Description = "Incentive";
                            sqlcmd.Parameters.Add("@Description", Description);
                            string AcctCode = "5134006";
                            sqlcmd.Parameters.Add("@AcctCode", dr["Account Code"].ToString());
                            double Price = 0;
                            double.TryParse(dr["Amount"].ToString(), out Price);
                            sqlcmd.Parameters.Add("@Price", Price);
                            string TaxCode = "EXEMPT";
                            int    TransNo = 1;
                            sqlcmd.Parameters.Add("@TaxCode", TaxCode);
                            sqlcmd.Parameters.Add("@LocCode", TransNo);
                            sqlcmd.Parameters.Add("@OcrCode", dr["WH Code"].ToString());
                            string B1Upload  = "N";
                            string Processed = "N";
                            sqlcmd.Parameters.Add("@Remarks", dr["Narration"].ToString());
                            sqlcmd.Parameters.Add("@B1Upload", B1Upload);
                            sqlcmd.Parameters.Add("@Processed", Processed);
                            sqlcmd.Parameters.Add("@Series", dr["Series"].ToString());
                            SAPvdm.insert(sqlcmd);
                        }
                    }
                }
                pnlHide.Visible = false;
                DataTable dtempty = new DataTable();
                grdReports.DataSource = dtempty;
                grdReports.DataBind();
                lblmsg.Text = "Successfully Saved";
            }
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.ToString();
        }
    }
Beispiel #9
0
 protected void BtnSave_Click(object sender, EventArgs e)
 {
     try
     {
         vdm = new VehicleDBMgr();
         DateTime    CreateDate    = VehicleDBMgr.GetTime(vdm.conn);
         SAPdbmanger SAPvdm        = new SAPdbmanger();
         DateTime    fromdate      = DateTime.Now;
         DataTable   dt            = (DataTable)Session["xportdata"];
         string[]    dateFromstrig = txtFromdate.Text.Split(' ');
         if (dateFromstrig.Length > 1)
         {
             if (dateFromstrig[0].Split('-').Length > 0)
             {
                 string[] dates = dateFromstrig[0].Split('-');
                 string[] times = dateFromstrig[1].Split(':');
                 fromdate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0);
             }
         }
         if (ddlSalesOffice.SelectedValue == "306")
         {
             fromdate = fromdate.AddDays(1);
         }
         else
         {
             fromdate = fromdate;
         }
         //cmd = new MySqlCommand("SELECT sno, BranchName, whcode, ladger_dr_code, tax, ntax, ledger_jv_code FROM branchdata WHERE (sno = @BranchID)");
         //cmd.Parameters.AddWithValue("@BranchID", ddlSalesOffice.SelectedValue);
         //DataTable dtwhscode = vdm.SelectQuery(cmd).Tables[0];
         //sqlcmd = new SqlCommand("SELECT CreateDate, PostingDate, DocDate, ReferenceNo, ItemCode, ItemName, MILKTYPE FROM EMROIGE WHERE (PostingDate BETWEEN @d1 AND @d2)  AND (WhsCode = @WhsCode)");
         //sqlcmd.Parameters.Add("@d1", GetLowDate(fromdate));
         //sqlcmd.Parameters.Add("@d2", GetHighDate(fromdate));
         //sqlcmd.Parameters.Add("@WhsCode", dtwhscode.Rows[0]["whcode"].ToString());
         //DataTable dtGI = SAPvdm.SelectQuery(sqlcmd).Tables[0];
         //if (dtGI.Rows.Count > 0)
         //{
         //    lblmsg.Text = "This Transaction already saved";
         //}
         //else
         //{
         DataTable dtGoodsIssue = new DataTable();
         foreach (DataRow dr in dt.Rows)
         {
             double amount = 0;
             double.TryParse(dr["Amount"].ToString(), out amount);
             string B1Upload  = "N";
             string Processed = "N";
             sqlcmd = new SqlCommand("SELECT CreateDate, PostingDate, DocDate, ReferenceNo, ItemCode, ItemName, MILKTYPE FROM EMROIGE WHERE (PostingDate BETWEEN @d1 AND @d2) AND (ItemCode=@ItemCode) AND (ReferenceNo = @ReferenceNo) AND (WhsCode = @WhsCode)");
             sqlcmd.Parameters.Add("@d1", GetLowDate(fromdate));
             sqlcmd.Parameters.Add("@d2", GetHighDate(fromdate));
             sqlcmd.Parameters.Add("@ReferenceNo", dr["JV No"].ToString());
             sqlcmd.Parameters.Add("@WhsCode", dr["whcode"].ToString());
             sqlcmd.Parameters.Add("@ItemCode", dr["Item Code"].ToString());
             dtGoodsIssue = SAPvdm.SelectQuery(sqlcmd).Tables[0];
             if (dtGoodsIssue.Rows.Count > 0)
             {
                 lblmsg.Text = "This Transaction already saved";
                 break;
             }
             else
             {
                 sqlcmd = new SqlCommand("Insert into EMROIGE (CreateDate,PostingDate,DocDate,ReferenceNo,ItemCode,ItemName,Price,Quantity,WhsCode,OcrCode,OcrCode2,Remarks,B1Upload,Processed,series,Milktype) values (@CreateDate,@PostingDate,@DocDate,@ReferenceNo,@ItemCode,@ItemName,@Price,@Quantity,@WhsCode,@OcrCode,@OcrCode2,@Remarks,@B1Upload,@Processed,@series,@Milktype)");
                 sqlcmd.Parameters.Add("@CreateDate", GetLowDate(fromdate));
                 sqlcmd.Parameters.Add("@PostingDate", GetLowDate(fromdate));
                 sqlcmd.Parameters.Add("@DocDate", GetLowDate(fromdate));
                 sqlcmd.Parameters.Add("@ReferenceNo", dr["JV No"].ToString());
                 sqlcmd.Parameters.Add("@ItemCode", dr["Item Code"].ToString());
                 sqlcmd.Parameters.Add("@ItemName", dr["Item Name"].ToString());
                 sqlcmd.Parameters.Add("@Price", amount);
                 sqlcmd.Parameters.Add("@Quantity", dr["Qty"].ToString());
                 sqlcmd.Parameters.Add("@WhsCode", dr["whcode"].ToString());
                 sqlcmd.Parameters.Add("@OcrCode", dr["whcode"].ToString());
                 sqlcmd.Parameters.Add("@OcrCode2", dr["Category Code"].ToString());
                 sqlcmd.Parameters.Add("@Remarks", dr["Narration"].ToString());
                 sqlcmd.Parameters.Add("@B1Upload", B1Upload);
                 sqlcmd.Parameters.Add("@Processed", Processed);
                 string series = "98";
                 sqlcmd.Parameters.Add("@series", series);
                 sqlcmd.Parameters.Add("@Milktype", dr["Milk Type"].ToString());
                 SAPvdm.insert(sqlcmd);
             }
         }
         if (dtGoodsIssue.Rows.Count > 0)
         {
             pnlHide.Visible = false;
             DataTable dtempty = new DataTable();
             grdReports.DataSource = dtempty;
             grdReports.DataBind();
             lblmsg.Text = "This Transaction already saved";
         }
         else
         {
             pnlHide.Visible = false;
             DataTable dtempty = new DataTable();
             grdReports.DataSource = dtempty;
             grdReports.DataBind();
             lblmsg.Text = "Successfully Saved";
         }
         //}
     }
     catch (Exception ex)
     {
         lblmsg.Text = ex.ToString();
     }
 }
Beispiel #10
0
 protected void BtnSave_Click(object sender, EventArgs e)
 {
     try
     {
         vdm          = new VehicleDBMgr();
         lbl_msg.Text = "";
         DateTime    CreateDate    = VehicleDBMgr.GetTime(vdm.conn);
         SAPdbmanger SAPvdm        = new SAPdbmanger();
         DateTime    fromdate      = DateTime.Now;
         DataTable   dt            = (DataTable)Session["xportdata"];
         string[]    dateFromstrig = txtFromdate.Text.Split(' ');
         if (dateFromstrig.Length > 1)
         {
             if (dateFromstrig[0].Split('-').Length > 0)
             {
                 string[] dates = dateFromstrig[0].Split('-');
                 string[] times = dateFromstrig[1].Split(':');
                 fromdate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0);
             }
         }
         foreach (DataRow dr in dt.Rows)
         {
             string AcctCode = dr["Ledger Code"].ToString();
             if (AcctCode == "")
             {
             }
             else
             {
                 sqlcmd = new SqlCommand("SELECT CreateDate, RefDate, DocDate FROM EMROJDT WHERE (RefDate BETWEEN @d1 AND @d2) AND (TransNo = @TNo) AND (AcctCode=@acccode)");
                 sqlcmd.Parameters.Add("@d1", GetLowDate(fromdate));
                 sqlcmd.Parameters.Add("@d2", GetHighDate(fromdate));
                 sqlcmd.Parameters.Add("@TNo", dr["JV No"].ToString());
                 sqlcmd.Parameters.Add("@acccode", AcctCode);
                 DataTable dtjv = SAPvdm.SelectQuery(sqlcmd).Tables[0];
                 if (dtjv.Rows.Count > 0)
                 {
                     lbl_msg.Text = "This Date Data already Saved";
                 }
                 else
                 {
                     sqlcmd = new SqlCommand("Insert into EMROJDT (CreateDate, RefDate, DocDate, TransNo, AcctCode, AcctName, Debit, Credit, B1Upload, Processed,Ref1,OcrCode,series) values (@CreateDate, @RefDate, @DocDate,@TransNo, @AcctCode, @AcctName, @Debit, @Credit, @B1Upload, @Processed,@Ref1,@OcrCode,@Series)");
                     sqlcmd.Parameters.Add("@CreateDate", CreateDate);
                     sqlcmd.Parameters.Add("@RefDate", GetLowDate(fromdate));
                     sqlcmd.Parameters.Add("@docdate", GetLowDate(fromdate));
                     sqlcmd.Parameters.Add("@Ref1", dr["JV No"].ToString());
                     sqlcmd.Parameters.Add("@TransNo", dr["JV No"].ToString());
                     sqlcmd.Parameters.Add("@AcctCode", dr["Ledger Code"].ToString());
                     sqlcmd.Parameters.Add("@AcctName", dr["Ledger Name"].ToString());
                     double amount = 0;
                     double.TryParse(dr["Amount"].ToString(), out amount);
                     if (amount < 0)
                     {
                         amount = Math.Abs(amount);
                         double Debit = 0;
                         sqlcmd.Parameters.Add("@Debit", Debit);
                         sqlcmd.Parameters.Add("@Credit", amount);
                     }
                     else
                     {
                         amount = Math.Abs(amount);
                         double Credit = 0;
                         sqlcmd.Parameters.Add("@Debit", amount);
                         sqlcmd.Parameters.Add("@Credit", Credit);
                     }
                     string B1Upload  = "N";
                     string Processed = "N";
                     sqlcmd.Parameters.Add("@B1Upload", B1Upload);
                     sqlcmd.Parameters.Add("@Processed", Processed);
                     sqlcmd.Parameters.Add("@OcrCode", dr["WH Code"].ToString());
                     sqlcmd.Parameters.Add("@series", dr["Series"].ToString());
                     if (amount == 0.0)
                     {
                     }
                     else
                     {
                         SAPvdm.insert(sqlcmd);
                     }
                 }
             }
         }
         pnlHide.Visible = false;
         DataTable dtempty = new DataTable();
         grdReports.DataSource = dtempty;
         grdReports.DataBind();
         if (lbl_msg.Text == "")
         {
             lbl_msg.Text = "Successfully Saved";
         }
     }
     catch (Exception ex)
     {
         msglbl.Text = ex.ToString();
     }
 }
Beispiel #11
0
 protected void BtnSave_Click(object sender, EventArgs e)
 {
     try
     {
         SAPdbmanger SAPvdm        = new SAPdbmanger();
         DateTime    fromdate      = DateTime.Now;
         DataTable   dt            = (DataTable)Session["xportdata"];
         string[]    dateFromstrig = txtFromdate.Text.Split(' ');
         if (dateFromstrig.Length > 1)
         {
             if (dateFromstrig[0].Split('-').Length > 0)
             {
                 string[] dates = dateFromstrig[0].Split('-');
                 string[] times = dateFromstrig[1].Split(':');
                 fromdate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0);
             }
         }
         foreach (DataRow dr in dt.Rows)
         {
             double amount = 0;
             double.TryParse(dr["Amount"].ToString(), out amount);
             string B1Upload  = "N";
             string Processed = "N";
             sqlcmd = new SqlCommand("SELECT CreateDate, PostingDate, DocDate, ReferenceNo, ItemCode, ItemName, MILKTYPE FROM EMROIGE WHERE (PostingDate BETWEEN @d1 AND @d2) AND (ItemCode=@ItemCode) AND (ReferenceNo = @ReferenceNo) AND (WhsCode = @WhsCode)");
             sqlcmd.Parameters.Add("@d1", GetLowDate(fromdate));
             sqlcmd.Parameters.Add("@d2", GetHighDate(fromdate));
             sqlcmd.Parameters.Add("@ReferenceNo", dr["JV No"].ToString());
             sqlcmd.Parameters.Add("@WhsCode", dr["whcode"].ToString());
             sqlcmd.Parameters.Add("@ItemCode", dr["Item Code"].ToString());
             DataTable dtGoodsIssue = SAPvdm.SelectQuery(sqlcmd).Tables[0];
             if (dtGoodsIssue.Rows.Count > 0)
             {
             }
             else
             {
                 sqlcmd = new SqlCommand("Insert into EMROIGE (CreateDate,PostingDate,DocDate,ReferenceNo,ItemCode,ItemName,Price,Quantity,WhsCode,OcrCode,OcrCode2,Remarks,B1Upload,Processed,series,Milktype) values (@CreateDate,@PostingDate,@DocDate,@ReferenceNo,@ItemCode,@ItemName,@Price,@Quantity,@WhsCode,@OcrCode,@OcrCode2,@Remarks,@B1Upload,@Processed,@series,@Milktype)");
                 sqlcmd.Parameters.Add("@CreateDate", GetLowDate(fromdate));
                 sqlcmd.Parameters.Add("@PostingDate", GetLowDate(fromdate));
                 sqlcmd.Parameters.Add("@DocDate", GetLowDate(fromdate));
                 sqlcmd.Parameters.Add("@ReferenceNo", dr["JV No"].ToString());
                 sqlcmd.Parameters.Add("@ItemCode", dr["Item Code"].ToString());
                 sqlcmd.Parameters.Add("@ItemName", dr["Item Name"].ToString());
                 sqlcmd.Parameters.Add("@Price", amount);
                 sqlcmd.Parameters.Add("@Quantity", dr["Qty"].ToString());
                 sqlcmd.Parameters.Add("@WhsCode", dr["whcode"].ToString());
                 sqlcmd.Parameters.Add("@OcrCode", dr["whcode"].ToString());
                 sqlcmd.Parameters.Add("@OcrCode2", dr["Category Code"].ToString());
                 sqlcmd.Parameters.Add("@Remarks", dr["Narration"].ToString());
                 sqlcmd.Parameters.Add("@B1Upload", B1Upload);
                 sqlcmd.Parameters.Add("@Processed", Processed);
                 string series = "240";
                 sqlcmd.Parameters.Add("@series", series);
                 sqlcmd.Parameters.Add("@Milktype", dr["Milk Type"].ToString());
                 SAPvdm.insert(sqlcmd);
             }
         }
         pnlHide.Visible = false;
         DataTable dtempty = new DataTable();
         grdReports.DataSource = dtempty;
         grdReports.DataBind();
         lblmsg.Text = "Successfully Saved";
     }
     catch (Exception ex)
     {
         lblmsg.Text = ex.ToString();
     }
 }
Beispiel #12
0
    protected void btn_save_click(object sender, EventArgs e)
    {
        try
        {
            vdm = new SalesDBManager();
            DateTime    CreateDate    = SalesDBManager.GetTime(vdm.conn);
            SAPdbmanger SAPvdm        = new SAPdbmanger();
            DateTime    fromdate      = DateTime.Now;
            DataTable   dt            = (DataTable)Session["xportdata"];
            string[]    dateFromstrig = dtp_FromDate.Text.Split(' ');
            if (dateFromstrig.Length > 1)
            {
                if (dateFromstrig[0].Split('-').Length > 0)
                {
                    string[] dates = dateFromstrig[0].Split('-');
                    string[] times = dateFromstrig[1].Split(':');
                    fromdate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0);
                }
            }
            fromdate = fromdate;
            foreach (DataRow dr in dt.Rows)
            {
                double amount     = 10;
                string B1Upload   = "N";
                string Processed  = "N";
                string ledgercode = dr["Item Code"].ToString();
                if (ledgercode == "")
                {
                }
                else
                {
                    sqlcmd = new SqlCommand("SELECT CreateDate, PostingDate, DocDate, ReferenceNo AS Processed, Series FROM EMROWTR WHERE (PostingDate BETWEEN @d1 AND @d2) AND (ItemCode=@ItemCode) AND (ReferenceNo = @ReferenceNo)");
                    sqlcmd.Parameters.Add("@d1", GetLowDate(fromdate));
                    sqlcmd.Parameters.Add("@d2", GetHighDate(fromdate));
                    sqlcmd.Parameters.Add("@ReferenceNo", dr["ReferenceNo"].ToString());
                    sqlcmd.Parameters.Add("@ItemCode", dr["Item Code"].ToString());
                    DataTable dtST = SAPvdm.SelectQuery(sqlcmd).Tables[0];
                    if (dtST.Rows.Count > 0)
                    {
                    }
                    else
                    {
                        sqlcmd = new SqlCommand("Insert into EMROWTR (CreateDate,PostingDate,DocDate,ReferenceNo,FromWhsCode,ToWhsCode,ItemCode,ItemName,Quantity,Price,OcrCode,OcrCode2,Remarks,B1Upload,Processed,series) values (@CreateDate,@PostingDate,@DocDate,@ReferenceNo,@FromWhsCode,@ToWhsCode,@ItemCode,@ItemName,@Quantity,@Price,@OcrCode,@OcrCode2,@Remarks,@B1Upload,@Processed,@series)");
                        sqlcmd.Parameters.Add("@CreateDate", GetLowDate(fromdate));
                        sqlcmd.Parameters.Add("@PostingDate", GetLowDate(fromdate));
                        sqlcmd.Parameters.Add("@DocDate", GetLowDate(fromdate));
                        sqlcmd.Parameters.Add("@ReferenceNo", dr["ReferenceNo"].ToString());
                        string fromwhcode = "SVDSPP02";
                        sqlcmd.Parameters.Add("@FromWhsCode", fromwhcode);
                        sqlcmd.Parameters.Add("@ToWhsCode", dr["Wh Code"].ToString());
                        sqlcmd.Parameters.Add("@ItemCode", dr["Item Code"].ToString());
                        sqlcmd.Parameters.Add("@ItemName", dr["Item Name"].ToString());
                        sqlcmd.Parameters.Add("@Quantity", dr["Qty"].ToString());
                        sqlcmd.Parameters.Add("@Price", dr["Price"].ToString());
                        sqlcmd.Parameters.Add("@OcrCode", fromwhcode);
                        sqlcmd.Parameters.Add("@OcrCode2", "");
                        sqlcmd.Parameters.Add("@Remarks", dr["Narration"].ToString());
                        sqlcmd.Parameters.Add("@B1Upload", B1Upload);
                        sqlcmd.Parameters.Add("@Processed", Processed);
                        string series = "241";
                        sqlcmd.Parameters.Add("@series", series);
                        SAPvdm.insert(sqlcmd);
                    }
                }
            }

            DataTable dtempty = new DataTable();
            grdReports.DataSource = dtempty;
            grdReports.DataBind();
            lblmsg.Text = "Successfully Saved";
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.ToString();
        }
    }