コード例 #1
0
    void btn_save_curdsection()
    {
        try
        {
            SalesDBManager SalesDB     = new SalesDBManager();
            DateTime       CreateDate  = sapDBmanager.GetTime(vdm.conn);
            sapDBmanager   SAPvdm      = new sapDBmanager();
            DateTime       fromdate    = DateTime.Now;
            int            currentyear = (fromdate.Year);
            int            NEXTYEAR    = currentyear + 1;
            string         CYER        = currentyear.ToString();
            string         NYEAR       = NEXTYEAR.ToString();
            string         fyear       = "1718";
            // fyear =
            string[] datestrig = dtp_FromDate.Text.Split(' ');
            if (datestrig.Length > 1)
            {
                if (datestrig[0].Split('-').Length > 0)
                {
                    string[] dates = datestrig[0].Split('-');
                    string[] times = datestrig[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 = sapDBmanager.GetTime(vdm.conn);
            string    datetime = ServerDateCurrentdate.ToString("MM/dd/yyyy");
            string    BranchID = Session["Branch_ID"].ToString();
            DataTable dt       = (DataTable)Session["xportdata"];
            if (dt.Rows.Count > 0)
            {
                DateTime doe = DateTime.Now;
                int      i   = 1;

                foreach (DataRow dr in dt.Rows)
                {
                    string   ocrcode2 = "";
                    string   DocDate  = dr["DocDate"].ToString();
                    DateTime dtdoc    = Convert.ToDateTime(DocDate);
                    cmd = 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");
                    cmd.Parameters.Add("@d1", GetLowDate(dtdoc));
                    cmd.Parameters.Add("@d2", GetHighDate(dtdoc));
                    cmd.Parameters.Add("@rno", dr["RefNo"].ToString());
                    cmd.Parameters.Add("@ItemCode", dr["ItemCode"].ToString());
                    cmd.Parameters.Add("@ItemName", dr["ItemName"].ToString());
                    cmd.Parameters.Add("@WhsCode", dr["WhsCode"].ToString());
                    DataTable dtSAPproduction = SAPvdm.SelectQuery(cmd).Tables[0];
                    if (dtSAPproduction.Rows.Count > 0)
                    {
                        lblmsg.Text = "This date data already Saved";
                    }
                    else
                    {
                        cmd = 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)");
                        string CDate       = dr["CreateDate"].ToString();
                        string PostingDate = dr["PostingDate"].ToString();
                        cmd.Parameters.Add("@CreateDate", CDate);
                        cmd.Parameters.Add("@PostingDate", PostingDate);
                        cmd.Parameters.Add("@DocDate", DocDate);
                        cmd.Parameters.Add("@ReferenceNo", dr["RefNo"].ToString());
                        cmd.Parameters.Add("@ItemCode", dr["ItemCode"].ToString());
                        cmd.Parameters.Add("@ItemName", dr["ItemName"].ToString());
                        cmd.Parameters.Add("@Quantity", dr["Production Quantity"].ToString());
                        cmd.Parameters.Add("@WhsCode", dr["WhsCode"].ToString());
                        cmd.Parameters.Add("@Price", dr["Price"].ToString());
                        //string ledger = "0";
                        //cmd.Parameters.Add("@Account", ledger);
                        cmd.Parameters.Add("@OcrCode", dr["WhsCode"].ToString());
                        cmd.Parameters.Add("@Remarks", dr["Remarks"].ToString());
                        cmd.Parameters.Add("@Series", "19");
                        cmd.Parameters.Add("@OcrCode2", dr["Ocrcode2"].ToString());
                        string B1Upload  = "N";
                        string Processed = "N";
                        cmd.Parameters.Add("@B1Upload", B1Upload);
                        cmd.Parameters.Add("@Processed", Processed);
                        SAPvdm.insert(cmd);
                    }
                }
            }
            DataTable dtempty = new DataTable();
            lblmsg.Text = "Successfully Saved";
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.ToString();
        }
    }
コード例 #2
0
 void btn_save_curdsection()
 {
     try
     {
         SalesDBManager SalesDB     = new SalesDBManager();
         DateTime       CreateDate  = sapDBmanager.GetTime(vdm.conn);
         sapDBmanager   SAPvdm      = new sapDBmanager();
         DateTime       fromdate    = DateTime.Now;
         int            currentyear = (fromdate.Year);
         int            NEXTYEAR    = currentyear + 1;
         string         CYER        = currentyear.ToString();
         string         NYEAR       = NEXTYEAR.ToString();
         string         fyear       = CYER + '-' + NYEAR;
         string[]       datestrig   = dtp_FromDate.Text.Split(' ');
         if (datestrig.Length > 1)
         {
             if (datestrig[0].Split('-').Length > 0)
             {
                 string[] dates = datestrig[0].Split('-');
                 string[] times = datestrig[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 = sapDBmanager.GetTime(vdm.conn);
         string    datetime = ServerDateCurrentdate.ToString("MM/dd/yyyy");
         string    BranchID = Session["Branch_ID"].ToString();
         DataTable dt       = (DataTable)Session["xportdata"];
         if (dt.Rows.Count > 0)
         {
             DateTime doe = DateTime.Now;
             int      i   = 1;
             cmd = new SqlCommand("SELECT * FROM EMROIGN WHERE CreateDate BETWEEN @d1 AND @d2");
             cmd.Parameters.Add("@d1", GetLowDate(fromdate));
             cmd.Parameters.Add("@d2", GetHighDate(fromdate));
             DataTable dtdata = SAPvdm.SelectQuery(cmd).Tables[0];
             if (dtdata.Rows.Count < 0)
             {
                 foreach (DataRow dr in dt.Rows)
                 {
                     string   date   = dr["CreateDate"].ToString();
                     string[] str    = date.Split('/');
                     string   dtdate = str[0].ToString();
                     string   month  = str[1].ToString();
                     string   year   = str[2].ToString();
                     string   refno  = "SVDS/PBK/" + fyear + "/" + dtdate + "" + month + "/" + i++ + "";
                     cmd = new SqlCommand("Insert into EMROIGN (CreateDate,PostingDate,DocDate,ReferenceNo,ItemCode,ItemName,Quantity,WhsCode,Price,Account,OcrCode,Remarks,B1Upload,Processed) values (@CreateDate,@PostingDate,@DocDate,@ReferenceNo,@ItemCode,@ItemName,@Quantity,@WhsCode,@Price,@Account,@OcrCode,@Remarks,@B1Upload,@Processed)");
                     string CDate       = dr["CreateDate"].ToString();
                     string PostingDate = dr["PostingDate"].ToString();
                     string DocDate     = dr["DocDate"].ToString();
                     cmd.Parameters.Add("@CreateDate", CDate);
                     cmd.Parameters.Add("@PostingDate", PostingDate);
                     cmd.Parameters.Add("@DocDate", DocDate);
                     cmd.Parameters.Add("@ReferenceNo", refno);
                     cmd.Parameters.Add("@ItemCode", dr["ItemCode"].ToString());
                     cmd.Parameters.Add("@ItemName", dr["ItemName"].ToString());
                     cmd.Parameters.Add("@Quantity", dr["Production Quantity"].ToString());
                     cmd.Parameters.Add("@WhsCode", dr["WhsCode"].ToString());
                     cmd.Parameters.Add("@Price", "0");
                     string ledger = "5134004";
                     cmd.Parameters.Add("@Account", ledger);
                     cmd.Parameters.Add("@OcrCode", dr["WhsCode"].ToString());
                     cmd.Parameters.Add("@Remarks", dr["Remarks"].ToString());
                     string B1Upload  = "N";
                     string Processed = "N";
                     cmd.Parameters.Add("@B1Upload", B1Upload);
                     cmd.Parameters.Add("@Processed", Processed);
                     SAPvdm.insert(cmd);
                 }
                 DataTable dtempty = new DataTable();
                 lblmsg.Text = "Successfully Saved";
             }
             else
             {
                 lblmsg.Text           = "This Date Data Alredy Exist In Datbase Plese Check it";
                 grdReports.DataSource = null;
                 grdReports.DataBind();
                 Session["xportdata"] = null;
             }
         }
     }
     catch (Exception ex)
     {
         lblmsg.Text = ex.ToString();
     }
 }