Esempio n. 1
0
        public void AddMajorHandHeldCounterMainHoldToSap(string branchCode, string documentNo, string officerID1, string officerID2)
        {
            var    counterHolds   = GetHandHeldCounterMainHoldByDocumentNo(branchCode, documentNo);
            string accountingYear = string.Empty;
            string officerID      = string.Empty;

            SAPProxyIII.ZDD_HH_CHKSTOCKTable tables = new SAPProxyIII.ZDD_HH_CHKSTOCKTable();

            using (var sapConnection = new SAP.Connector.SAPConnection(GlobalContext.SapDestination))
            {
                using (var prx = new SAPProxyIII.UWProxy())
                {
                    prx.Connection = sapConnection;

                    foreach (var item in counterHolds)
                    {
                        var zdd = new SAPProxyIII.ZDD_HH_CHKSTOCK();
                        zdd.Iblnr       = item.Iblnr;
                        zdd.Gjahr       = item.Gjahr;
                        zdd.Zeili       = item.Zeili;
                        zdd.Matnr       = item.Matnr;
                        zdd.Ean11       = item.Ean11;
                        zdd.Maktx       = item.Maktx;
                        zdd.Shelf       = item.Shelf;
                        zdd.Bin_Code    = item.BinCode;
                        zdd.Erfmg_Sku   = item.ErfmgSku;
                        zdd.Erfme_Sku   = item.ErfmeSku;
                        zdd.Ratio       = item.Ratio;
                        zdd.Erfmg_Sales = item.ErfmgSales;
                        zdd.Erfme_Sales = item.ErfmeSales;

                        accountingYear = item.Gjahr;
                        officerID      = item.Createuser;

                        tables.Add(zdd);
                    }

                    try
                    {
                        prx.Zdd_Handheld_Checkstock(accountingYear, documentNo, "X", officerID1, officerID1, ref tables);

                        using (var db = new DbManager(branchCode))
                        {
                            db.SetCommand(GetSql(33), db.Parameter("@DocumentNo", documentNo)).ExecuteNonQuery();
                        }

                        prx.CommitWork();
                    }
                    catch (Exception ex)
                    {
                        prx.RollbackWork();
                        throw ex;
                    }
                }
            }
        }
Esempio n. 2
0
        private void AddHandHeldCheckProductToSAP(string userCode, string userName, string employeeID, string locationCode, string warehouseCode, string branchCode, List <LocationDescription> locationDescriptions, List <ProductBarcode> products, string remark)
        {
            using (var sapConnection = new SAP.Connector.SAPConnection(GlobalContext.SapDestination))
            {
                using (var prx = new SAPProxyIII.UWProxy())
                {
                    prx.Connection = sapConnection;


                    SAPProxyIII.ZDD_HH_CHECKAREATable zdd_hh_checkarea = new SAPProxyIII.ZDD_HH_CHECKAREATable();
                    SAPProxyIII.ZDD_HH_CHECKAREA      area             = new SAPProxyIII.ZDD_HH_CHECKAREA();

                    foreach (var item in locationDescriptions)
                    {
                        #region เก็บข้อมูลลง Internal Table
                        area.Bin_Code = locationCode;
                        switch (item.ID + 1)
                        {
                        case 1:
                            area.F01 = " ";
                            if (item.Checked)
                            {
                                area.F01 = "X";
                            }
                            break;

                        case 2:
                            area.F02 = " ";
                            if (item.Checked)
                            {
                                area.F02 = "X";
                            }
                            break;

                        case 3:
                            area.F03 = " ";
                            if (item.Checked)
                            {
                                area.F03 = "X";
                            }
                            break;

                        case 4:
                            area.F04 = " ";
                            if (item.Checked)
                            {
                                area.F04 = "X";
                            }
                            break;

                        case 5:
                            area.F05 = " ";
                            if (item.Checked)
                            {
                                area.F05 = "X";
                            }
                            break;

                        case 6:
                            area.F06 = " ";
                            if (item.Checked)
                            {
                                area.F06 = "X";
                            }
                            break;

                        case 7:
                            area.F07 = " ";
                            if (item.Checked)
                            {
                                area.F07 = "X";
                            }
                            break;

                        case 8:
                            area.F08 = " ";
                            if (item.Checked)
                            {
                                area.F08 = "X";
                            }
                            break;

                        case 9:
                            area.F09 = " ";
                            if (item.Checked)
                            {
                                area.F09 = "X";
                            }
                            break;

                        case 10:
                            area.F10 = 0;
                            if (item.Checked)
                            {
                                short areaF10 = 0;
                                Int16.TryParse(item.BlankNumber, out areaF10);
                                area.F10 = areaF10;
                            }
                            break;

                        case 11:
                            area.F11 = " ";
                            if (item.Checked)
                            {
                                area.F11 = "X";
                            }
                            break;

                        case 12:
                            area.F12 = " ";
                            if (item.Checked)
                            {
                                area.F12 = "X";
                            }
                            break;

                        case 13:
                            area.F13 = " ";
                            if (item.Checked)
                            {
                                area.F13 = "X";
                            }
                            break;

                        case 14:
                            area.F14 = " ";
                            if (item.Checked)
                            {
                                area.F14 = "X";
                            }
                            break;

                        case 15:
                            area.F15 = " ";
                            if (item.Checked)
                            {
                                area.F15 = "X";
                            }
                            break;

                        case 16:
                            area.F16 = " ";
                            if (item.Checked)
                            {
                                area.F16 = "X";
                            }
                            break;

                        case 17:
                            area.F17 = " ";
                            if (item.Checked)
                            {
                                area.F17 = "X";
                            }
                            break;

                        case 18:
                            area.F18 = " ";
                            if (item.Checked)
                            {
                                area.F18 = "X";
                            }
                            break;

                        case 19:
                            area.F19 = " ";
                            if (item.Checked)
                            {
                                area.F19 = "X";
                            }
                            break;

                        case 20:
                            area.Expoint = 0;
                            if (item.Checked)
                            {
                                short areaExpoint = 0;
                                Int16.TryParse(item.BlankNumber, out areaExpoint);
                                area.Expoint = areaExpoint;
                            }
                            break;

                        default:
                            break;
                        }
                        #endregion
                    }

                    area.Remark = remark;
                    area.Lgort  = warehouseCode;
                    area.Werks  = branchCode;

                    using (DbManager db = new DbManager(branchCode))
                    {
                        db.Command.CommandTimeout = 200;
                        var sql        = GetSql(28);
                        var documentNo = this.GetHandHeldCheckProductDocumentNo(branchCode);
                        try
                        {
                            db.BeginTransaction();

                            foreach (var item in products)
                            {
                                area.Matnr = item.ProductCode;
                                area.Meins = item.UnitCode;
                                zdd_hh_checkarea.Add(area);
                                prx.Zdd_Handheld_Checkarea(userName, employeeID, ref zdd_hh_checkarea);
                                if (zdd_hh_checkarea.Count > 0)
                                {
                                    if (!string.IsNullOrEmpty(zdd_hh_checkarea[0].Chkareano))
                                    {
                                        db.SetCommand(sql,
                                                      db.Parameter("@DOCNO", documentNo),
                                                      db.Parameter("@LOCATION", locationCode),
                                                      db.Parameter("@DOCDATE", DateTime.Now.Date),
                                                      db.Parameter("@USERID", userCode),
                                                      db.Parameter("@OFFICERID", employeeID),
                                                      db.Parameter("@CHKAREANO", zdd_hh_checkarea[0].Chkareano))
                                        .ExecuteNonQuery();

                                        documentNo = PrepareHandHeldCheckProductDocumentNo(documentNo);
                                    }
                                }
                            }

                            prx.CommitWork();
                            db.CommitTransaction();
                        }
                        catch (Exception ex)
                        {
                            prx.RollbackWork();
                            db.RollbackTransaction();
                            throw ex;
                        }
                    }
                }
            }
        }