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();
        }
    }
Exemplo n.º 2
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);
                }
            }
            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("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", GetLowDate(fromdate));
                    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";
                    string series    = "17";
                    sqlcmd.Parameters.Add("@B1Upload", B1Upload);
                    sqlcmd.Parameters.Add("@Processed", Processed);
                    sqlcmd.Parameters.Add("@ocrcode", whCode);
                    sqlcmd.Parameters.Add("@series", series);
                    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();
        }
    }
Exemplo n.º 3
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);
             }
         }
         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;
     }
 }
Exemplo n.º 4
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();
        }
    }
Exemplo n.º 5
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;
     }
 }
Exemplo n.º 6
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);
                }
            }
            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 sno         = row.Cells[0].Text;
                        string VoucherDate = row.Cells[1].Text;
                        string VoucherNo   = row.Cells[2].Text;
                        string whcode      = row.Cells[3].Text;
                        string VoucherType = row.Cells[4].Text;
                        string Ledgercode  = row.Cells[5].Text;
                        string LedgerDr    = row.Cells[6].Text;;
                        //string CreatedBy = row.Cells[5].Text;
                        string PaidDate     = row.Cells[7].Text;
                        string customercode = row.Cells[8].Text;
                        string LedgerCr     = row.Cells[9].Text;
                        string Amount       = row.Cells[10].Text;
                        string Narration    = row.Cells[11].Text;
                        double amount       = 0;
                        double.TryParse(Amount, out amount);
                        //string customercode = dr["Customer Code"].ToString();
                        double num;
                        if (double.TryParse(customercode, out num))
                        {
                            string Customercode = row.Cells[8].Text;
                            if (Ledgercode == "" || Customercode == "")
                            {
                            }
                            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", Ledgercode);
                                sqlcmd.Parameters.Add("@AcctName", LedgerDr);
                                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", Customercode);
                                sqlcmd.Parameters.Add("@AcctName", LedgerCr);
                                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("Insert into EMRORCT (CreateDate,PaymentDate,DOE,ReferenceNo,CardCode,Remarks,PaymentMode,PaymentSum,OcrCode,B1Upload,Processed,AcctNo,series) values(@CreateDate,@PaymentDate,@DOE,@ReferenceNo,@CardCode,@Remarks,@PaymentMode,@PaymentSum,@OcrCode,@B1Upload,@Processed,@AcctNo,@series)");
                            sqlcmd.Parameters.Add("@CreateDate", GetLowDate(fromdate));
                            sqlcmd.Parameters.Add("@PaymentDate", GetLowDate(fromdate));
                            sqlcmd.Parameters.Add("@DOE", GetLowDate(fromdate));
                            sqlcmd.Parameters.Add("@ReferenceNo", VoucherNo);
                            sqlcmd.Parameters.Add("@CardCode", VoucherNo);
                            sqlcmd.Parameters.Add("@Remarks", Narration);
                            //sqlcmd.Parameters.Add("@InvoiceNo", dr["Voucher No"].ToString());
                            sqlcmd.Parameters.Add("@PaymentMode", PaymentMode);
                            sqlcmd.Parameters.Add("@PaymentSum", amount);
                            sqlcmd.Parameters.Add("@OcrCode", whcode);
                            sqlcmd.Parameters.Add("@B1Upload", B1Upload);
                            sqlcmd.Parameters.Add("@Processed", Processed);
                            sqlcmd.Parameters.Add("@AcctNo", Ledgercode);
                            string series = "15";
                            sqlcmd.Parameters.Add("@series", series);
                            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();
        }
    }
Exemplo n.º 7
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        try
        {
            DBManager   SalesDB    = new DBManager();
            DateTime    CreateDate = DBManager.GetTime(vdm.conn);
            SAPdbmanger SAPvdm     = new SAPdbmanger();

            DateTime  fromdate = DateTime.Now;
            DataTable dt       = (DataTable)Session["xportdata"];
            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("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", GetLowDate(fromdate));
                    sqlcmd.Parameters.Add("@RefDate", GetLowDate(fromdate));
                    sqlcmd.Parameters.Add("@docdate", GetLowDate(fromdate));
                    sqlcmd.Parameters.Add("@Ref1", dr["Invoice"].ToString());
                    sqlcmd.Parameters.Add("@OCRCODE", dr["WH Code"].ToString());
                    // int TransNo = 1;
                    sqlcmd.Parameters.Add("@Series", "17");
                    sqlcmd.Parameters.Add("@TransNo", dr["Invoice"].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);
                    SAPvdm.insert(sqlcmd);
                }
            }
            DataTable dtempty = new DataTable();
            grdReports.DataSource = dtempty;
            grdReports.DataBind();
            lblmsg.Text = "Successfully Saved";
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.ToString();
        }
    }
Exemplo n.º 8
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 = 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 PaymentMode = "CASH";
                double amount      = 0;
                double.TryParse(dr["Amount"].ToString(), out amount);
                string   B1Upload  = "N";
                string   Processed = "N";
                string   date      = dr["Voucher Date"].ToString();
                DateTime from_date = Convert.ToDateTime(date);
                sqlcmd = new SqlCommand("Insert into EMROJDTP (CreateDate, RefDate, DocDate, TransNo,TransCode, AcctCode, AcctName, Debit, Credit, B1Upload, Processed,Ref1,OcrCode,Remarks) values (@CreateDate, @RefDate, @DocDate,@TransNo,@TransCode, @AcctCode, @AcctName, @Debit, @Credit, @B1Upload, @Processed,@Ref1,@OcrCode,@Remarks)");
                sqlcmd.Parameters.Add("@CreateDate", CreateDate);
                sqlcmd.Parameters.Add("@RefDate", GetLowDate(from_date));
                sqlcmd.Parameters.Add("@docdate", GetLowDate(from_date));
                sqlcmd.Parameters.Add("@Ref1", dr["Voucher No"].ToString());
                string TransCode = "T1";
                sqlcmd.Parameters.Add("@TransNo", dr["Voucher No"].ToString());
                sqlcmd.Parameters.Add("@TransCode", TransCode);
                sqlcmd.Parameters.Add("@AcctCode", dr["Debit Code"].ToString());
                sqlcmd.Parameters.Add("@AcctName", dr["Ledger (Dr)"].ToString());
                double.TryParse(dr["Amount"].ToString(), 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", dr["whcode"].ToString());
                sqlcmd.Parameters.Add("@Remarks", dr["Narration"].ToString());
                SAPvdm.insert(sqlcmd);

                sqlcmd = new SqlCommand("Insert into EMROJDTP (CreateDate, RefDate, DocDate, TransNo,TransCode, AcctCode, AcctName, Debit, Credit, B1Upload, Processed,Ref1,OcrCode,Remarks) values (@CreateDate, @RefDate, @DocDate,@TransNo,@TransCode, @AcctCode, @AcctName, @Debit, @Credit, @B1Upload, @Processed,@Ref1,@OcrCode,@Remarks)");
                sqlcmd.Parameters.Add("@CreateDate", CreateDate);
                sqlcmd.Parameters.Add("@RefDate", GetLowDate(from_date));
                sqlcmd.Parameters.Add("@docdate", GetLowDate(from_date));
                sqlcmd.Parameters.Add("@Ref1", dr["Voucher No"].ToString());
                sqlcmd.Parameters.Add("@TransNo", dr["Voucher No"].ToString());
                sqlcmd.Parameters.Add("@TransCode", TransCode);
                sqlcmd.Parameters.Add("@AcctCode", dr["Credit Code"].ToString());
                sqlcmd.Parameters.Add("@AcctName", dr["Ledger (Cr)"].ToString());
                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", dr["whcode"].ToString());
                sqlcmd.Parameters.Add("@Remarks", dr["Narration"].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();
        }
    }
Exemplo n.º 9
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();
        }
    }
Exemplo n.º 10
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);
                }
            }

            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();
        }
    }
Exemplo n.º 11
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();
     }
 }
Exemplo n.º 12
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();
     }
 }
 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);
             }
         }
         string ocrcode2 = "", remarks = "";
         foreach (DataRow dr in dt.Rows)
         {
             string itemcode = dr["ITEMCODE"].ToString();
             if (itemcode == "")
             {
             }
             else
             {
                 cmd = new SqlCommand("insert into EMROPDN (CreateDate, CardCode, CardName, TaxDate, DocDate, DocDueDate, ReferenceNo, ItemCode, Dscription, WhsCode, Quantity, Price, VAT_Percent, LineTotal, OcrCode, OcrCode2, REMARKS, B1Upload, Processed) values (@CreateDate, @CardCode, @CardName, @TaxDate, @DocDate, @DocDueDate, @ReferenceNo, @ItemCode, @Dscription, @WhsCode, @Quantity, @Price, @VAT_Percent, @LineTotal, @OcrCode, @OcrCode2, @REMARKS, @B1Upload, @Processed)");
                 cmd.Parameters.Add("@CreateDate", fromdate);
                 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("@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);
                 double vatpercent = 0;
                 double.TryParse(dr["VAT PERCENT"].ToString(), out vatpercent);
                 cmd.Parameters.Add("@VAT_Percent", vatpercent);
                 double linetotal = 0;
                 double.TryParse(dr["LINE TOTAL"].ToString(), out linetotal);
                 cmd.Parameters.Add("@LineTotal", linetotal);
                 cmd.Parameters.Add("@OcrCode", dr["WARE HOUSE CODE"].ToString());
                 cmd.Parameters.Add("@OcrCode2", ocrcode2);
                 cmd.Parameters.Add("@REMARKS", remarks);
                 string B1Upload  = "N";
                 string Processed = "N";
                 cmd.Parameters.Add("@B1Upload", B1Upload);
                 cmd.Parameters.Add("@Processed", Processed);
                 SAPvdm.insert(cmd);
             }
         }
         lblmsg.Text = "Saved successfully";
         DataTable dtempty = new DataTable();
         grdReports.DataSource = dtempty;
         grdReports.DataBind();
     }
     catch (Exception ex)
     {
         lblmsg.Text       = ex.Message;
         hidepanel.Visible = false;
     }
 }
Exemplo n.º 14
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();
        }
    }