示例#1
0
        private void BindData()
        {
            gvProductInfo.DataSource       = null;
            bsProductOutOfStock.DataSource = null;
            bsProductOutOfStock.ResetBindings(false);
            txtProductCode.Text         = null;
            txtProductName.Text         = null;
            txtGroupingofmaterials.Text = null;

            string productCodeOrBarcode = txtProductCodeOrBarcode.Text.Trim();
            var    EndPoint             = GlobalContext.ServerEndpointAddress;
            var    ServiceUrl           = GlobalContext.remoteAddress;
            var    cnn = new DoHome.HandHeld.Client.SAPCnn.MobileService();

            cnn.Url = ServiceUrl.Replace("localhost", EndPoint);
            var productBarcodes = cnn.ProductBarcodeGetByProductCodeOrBarcode1(productCodeOrBarcode, GlobalContext.WarehouseCode, GlobalContext.BranchCode, GlobalContext.IsShowPrice, GlobalContext.IsShowPrice);

            if (productBarcodes != null && productBarcodes.Length > 0)
            {
                txtGroupingofmaterials.Text = cnn.SapDepartmentTextGetByProductCode(GlobalContext.BranchCode, productCodeOrBarcode);
                var productBarcode = productBarcodes.First();
                txtProductCode.Text = productBarcode.ProductCode;
                txtProductName.Text = productBarcode.ProductName;
                this.BindGridViewProductOutOfStock(productBarcode.ProductCode);
            }

            //binding datasource on gridview.
            gvProductInfo.DataSource     = productBarcodes;
            txtProductCodeOrBarcode.Text = null;
        }
        private void BindLocationData()
        {
            var locationCode = txtLocationCode.Text.ToUpper();

            if (locationCode.IndexOf(Convert.ToChar(".")) > -1)
            {
                txtLocationCode.Text = null;
                txtLocationCode.Focus();
                return;
            }
            else if (Utils.CheckIsDigitOnly(locationCode))
            {
                txtLocationCode.Text = null;
                txtLocationCode.Focus();
                return;
            }

            try
            {
                Cursor.Current = Cursors.WaitCursor;

                if (!OfflineMode)
                {
                    var EndPoint   = GlobalContext.ServerEndpointAddress;
                    var ServiceUrl = GlobalContext.remoteAddress;
                    var cnn        = new DoHome.HandHeld.Client.SAPCnn.MobileService();
                    cnn.Url = ServiceUrl.Replace("localhost", EndPoint);
                    var location = cnn.LocationGetByCode(locationCode, GlobalContext.WarehouseCode);
                    if (location == null)
                    {
                        GlobalMessageBox.ShowInfomation("ไม่พบตำแหน่งจัดเก็บสินค้านี้ ในระบบ");
                        return;
                    }
                    txtLocationCode.Text = location.Code;
                }
                else
                {
                    txtLocationCode.Text = locationCode;
                }

                //chkOffline.Enabled = false;
                txtLocationCode.Enabled = false;
                txtBarcode.Enabled      = true;
                txtEmployeeCode.Enabled = true;
                btnSearchUser.Enabled   = true;
                txtBarcode.Focus();
            }
            catch (Exception ex) { GlobalMessageBox.ShowError(ex.Message); }
            finally { Cursor.Current = Cursors.Default; }
        }
示例#3
0
        public bool SyncForms()
        {
            var EndPoint   = GlobalContext.ServerEndpointAddress;
            var ServiceUrl = GlobalContext.remoteAddress;

            try
            {
                var cnn = new DoHome.HandHeld.Client.SAPCnn.MobileService();
                cnn.Url = ServiceUrl.Replace("localhost", EndPoint);
                var ListOfForms = cnn.GetTopstockForms();
                if (ListOfForms.Count() > 0)
                {
                    try
                    {
                        using (SqlCeConnection con = new SqlCeConnection(SqlHelper.SqlCeConnectionString))
                        {
                            con.Open();
                            using (SqlCeCommand com = new SqlCeCommand("Delete TopstockForm", con))
                            {
                                com.ExecuteNonQuery();
                                com.CommandText = "Insert into TopstockForm (FormCode,FormName) Values(@FormCode,@FormName)";
                                foreach (var item in ListOfForms)
                                {
                                    com.Parameters.Clear();
                                    com.Parameters.AddWithValue("@FormCode", item.FormCode);
                                    com.Parameters.AddWithValue("@FormName", item.FromName);
                                    com.ExecuteNonQuery();
                                    if (item.FormCode.ToString().Trim() == "ZTOPST2")
                                    {
                                        GlobalContext.IndexFormType = 0;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(true);
        }
示例#4
0
        private void BindLocationData()
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                var locationCode = txtLocationCode.Text.Trim().ToUpper();
                if (!OfflineMode)
                {
                    var EndPoint   = GlobalContext.ServerEndpointAddress;
                    var ServiceUrl = GlobalContext.remoteAddress;
                    var cnn        = new DoHome.HandHeld.Client.SAPCnn.MobileService();
                    cnn.Url = ServiceUrl.Replace("localhost", EndPoint);
                    var location = cnn.LocationGetByCode(locationCode, GlobalContext.WarehouseCode);
                    //var location = ServiceHelper.MobileServices.LocationGetByCode(locationCode, GlobalContext.WarehouseCode);
                    ////var isExists = LocationManager.CheckExistsLocation(locationCode);
                    if (location == null)
                    {
                        Cursor.Current = Cursors.Default;
                        GlobalMessageBox.ShowInfomation("ไม่พบตำแหน่งจัดเก็บสินค้านี้ ในระบบ");
                        return;
                    }

                    if (!CheckIsCreateLocationToday())
                    {
                        return;
                    }
                }
                this.txtLocationCode.Text    = locationCode;
                this.txtLocationCode.Enabled = false;
                this.txtProductCode.Enabled  = true;
                this.txtEmployeeCode.Enabled = true;
                this.btnSearchUser.Enabled   = true;
                this.txtProductCode.Focus();
                Cursor.Current = Cursors.Default;
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                GlobalMessageBox.ShowError(ex.Message);
            }
            finally { Cursor.Current = Cursors.Default; }
        }
示例#5
0
        private void AddLocationCode(string productOrBarcode)
        {
/* Begin BEE Edit เปลี่ยนให้แสดงทุกหน่วยสินค้า ตามที่ Loss แจ้ง 2012-11-14
 *          var product = ServiceHelper.MobileServices.ProductBarcodeGetByProductCodeOrBarcode3(GlobalContext.BranchCode, productOrBarcode);
 *
 *          if (product != null)
 *          {
 *              var labelPrice = new LabelPrintProductDetail();
 *              labelPrice.Productcode = product.ProductCode;
 *              labelPrice.Productname = product.ProductName;
 *              labelPrice.Barcode = product.Barcode;
 *              labelPrice.Unitcode = product.UnitCode;
 *              labelPrice.Unitname = product.UnitName;
 *              labelPrice.OthUnitcode = labelPrice.Unitcode;
 *              labelPrice.OthUnitname = labelPrice.Unitname;
 *              labelPrice.PrintLabelTypeCode = cmbPrintType.SelectedValue.ToString();
 *              //var productPrice = ServiceHelper.MobileServices.ProductPriceGetCurrentPrice(GlobalContext.BranchCode, labelPrice.Productcode, labelPrice.Unitcode);
 *              //if (productPrice != null)
 *              //{
 *              //    labelPrice.Sellprice = productPrice.Saleprice;
 *              //    labelPrice.Pricedate = productPrice.Begindate;
 *              //    labelPrice.OthUnitprice = labelPrice.Sellprice;
 *              //}
 *
 *              labelPrice.Sellprice = product.ProductPrice;
 *              labelPrice.OthUnitprice = labelPrice.Sellprice;
 *
 *              labelPrice.DisplayOrder = _labelPrice.Count + 1;
 *              labelPrice.DisplayOrderSpecified = true;
 *              _labelPrice.Add(labelPrice);
 *
 *              this.BindGridview();
 *          }
 * End BEE Edit เปลี่ยนให้แสดงทุกหน่วยสินค้า ตามที่ Loss แจ้ง 2012-11-14 */

            //_labelPrice = new List<LabelPrintProductDetail>();
            var EndPoint   = GlobalContext.ServerEndpointAddress;
            var ServiceUrl = GlobalContext.remoteAddress;
            var cnn        = new DoHome.HandHeld.Client.SAPCnn.MobileService();

            cnn.Url = ServiceUrl.Replace("localhost", EndPoint);
            var product = (cnn.ProductBarcodeGetByProductCodeOrBarcode5(GlobalContext.BranchCode, productOrBarcode, GlobalContext.WarehouseCode));

            if (product != null)
            {
                if (product.Count() > 0)
                {
                    var frm = new SelectUnitPrice(product, chkPosition.Checked, productOrBarcode);
                    frm.ShowDialog();
                    if (frm.IsUse)
                    {
                        product = frm._ProductRT;
                    }
                    else
                    {
                        return;
                    }
                    if (chkPosition.Checked)
                    {
                        var frms = new SelectProductPosition(product);
                        frms.ShowDialog();
                        if (frms.IsUse)
                        {
                            product = frms._ProductRT;
                        }
                        else
                        {
                            return;
                        }
                    }
                    for (int I = 0; I < _labelPrice.Count; I++)
                    {
                        _labelPrice[I].DisplayOrder = I + 1;
                    }
                    foreach (var item in product)
                    {
                        var labelPrice = new LabelPrintProductDetailLocal();
                        labelPrice.Productcode           = item.ProductCode;
                        labelPrice.Productname           = item.ProductName;
                        labelPrice.Barcode               = item.Barcode;
                        labelPrice.Unitcode              = item.UnitCode;
                        labelPrice.Unitname              = item.UnitName;
                        labelPrice.OthUnitcode           = labelPrice.Unitcode;
                        labelPrice.OthUnitname           = labelPrice.Unitname;
                        labelPrice.PrintLabelTypeCode    = cmbPrintType.SelectedValue.ToString();
                        labelPrice.Sellprice             = item.ProductPrice;
                        labelPrice.OthUnitprice          = labelPrice.Sellprice;
                        labelPrice.Locationcode          = "";
                        labelPrice.DisplayOrder          = _labelPrice.Count + 1;
                        labelPrice.DisplayOrderSpecified = true;
                        labelPrice.ProductLoggr          = item.LOGGR;
                        labelPrice.ProductPosition       = item.PositionCode;
                        _labelPrice.Add(labelPrice);
                    }
                    this.BindGridview();
                }
                else
                {
                    MessageBox.Show("ไม่พบข้อมูลสินค้า", "คำเตือน");
                }
            }
            else
            {
                MessageBox.Show("ไม่พบข้อมูลสินค้า", "คำเตื่อน");
            }
        }
示例#6
0
        private void BindGridViewProductOutOfStock(string productCode)
        {
            List <ProductLocation> productLocations = new List <ProductLocation>();
            var EndPoint   = GlobalContext.ServerEndpointAddress;
            var ServiceUrl = GlobalContext.remoteAddress;
            var cnn        = new DoHome.HandHeld.Client.SAPCnn.MobileService();

            cnn.Url = ServiceUrl.Replace("localhost", EndPoint);
            var productLocationResult = cnn.ProductLocationGetAllByProductCode(productCode, GlobalContext.BranchCode, GlobalContext.WarehouseCode);

            foreach (var item in productLocationResult)
            {
                ProductLocation pro = new ProductLocation();
                pro.BalanceQuantity          = item.BalanceQuantity;
                pro.BalanceQuantitySpecified = item.BalanceQuantitySpecified;
                pro.BalanceQuantityText      = item.BalanceQuantityText;
                pro.CreateDate            = item.CreateDate;
                pro.CreateDateSpecified   = item.CreateDateSpecified;
                pro.DisplayOrder          = item.DisplayOrder;
                pro.DisplayOrderSpecified = item.DisplayOrderSpecified;
                pro.DocumentDate          = item.DocumentDate;
                pro.DocumentDateSpecified = item.DocumentDateSpecified;
                pro.DocumentNo            = item.DocumentNo;
                pro.LocationCode          = item.LocationCode;
                pro.LocationStatus        = item.LocationStatus;
                pro.LocationType          = item.LocationType;
                pro.MaxStock             = item.MaxStock;
                pro.MaxStockSpecified    = item.MaxStockSpecified;
                pro.OfficerID            = item.OfficerID;
                pro.PriceStatus          = item.PriceStatus;
                pro.ProductBarcode       = item.ProductBarcode;
                pro.ProductCode          = item.ProductCode;
                pro.ProductName          = item.ProductName;
                pro.ProductUnitCode      = item.ProductUnitCode;
                pro.ProductUnitName      = item.ProductUnitName;
                pro.PutDeep              = item.PutDeep;
                pro.PutDeepSpecified     = item.PutDeepSpecified;
                pro.PutLevel             = item.PutLevel;
                pro.PutLevelSpecified    = item.PutLevelSpecified;
                pro.PutQuantity          = item.PutQuantity;
                pro.PutQuantitySpecified = item.PutQuantitySpecified;
                pro.RandomText           = item.RandomText;
                pro.Remark                     = item.Remark;
                pro.RequestPrintLabel          = item.RequestPrintLabel;
                pro.RequestPrintLabelSpecified = item.RequestPrintLabelSpecified;
                pro.SalePrice                  = item.SalePrice;
                pro.SalePriceSpecified         = item.SalePriceSpecified;
                pro.ShopPrice                  = item.ShopPrice;
                pro.ShopPriceSpecified         = item.ShopPriceSpecified;
                pro.StatusText                 = item.StatusText;
                pro.UserID                     = item.UserID;
                pro.WarehouseCode              = item.WarehouseCode;
                pro.WarehouseName              = item.WarehouseName;
                productLocations.Add(pro);
            }

            if (productLocationResult != null)
            {
                bsProductOutOfStock.DataSource   = productLocations;
                btnSaveProductOutOfStock.Enabled = true;
            }
        }
 private void BindData()
 {
     if (OfflineMode)
     {
         txtLocationCodeScan.Text     = txtLocationCodeScan.Text.ToUpper().Trim();
         txtLocationCodeScan.ReadOnly = true;
         btnAdd.Enabled       = true;
         btnInsert.Enabled    = true;
         btnEdit.Enabled      = true;
         btnDelete.Enabled    = true;
         btnDeleteAll.Enabled = true;
         btnSave.Enabled      = true;
         chkOffline.Enabled   = false;
     }
     else
     {
         var EndPoint   = GlobalContext.ServerEndpointAddress;
         var ServiceUrl = GlobalContext.remoteAddress;
         try
         {
             //เรียกแบบ ธรรมดาจะสามารถแก้ไข CFF ERROR ได้
             var cnn = new DoHome.HandHeld.Client.SAPCnn.MobileService();
             cnn.Url = ServiceUrl.Replace("localhost", EndPoint);
             var location = cnn.LocationGetByCode(txtLocationCodeScan.Text.Trim().ToUpper(), GlobalContext.WarehouseCode);
             //var location = ServiceHelper.MobileServices.LocationGetByCode(txtLocationCodeScan.Text.Trim().ToUpper(), GlobalContext.WarehouseCode);
             txtLocationCodeScan.Text = null;
             if (location != null)
             {
                 txtLocationCodeScan.Text     = location.Code;
                 txtLocationCodeScan.ReadOnly = true;
                 btnAdd.Enabled       = true;
                 btnInsert.Enabled    = true;
                 btnEdit.Enabled      = true;
                 btnDelete.Enabled    = true;
                 btnDeleteAll.Enabled = true;
                 btnSave.Enabled      = true;
                 chkOffline.Enabled   = true;
                 List <ProductLocation> productLocations = new List <ProductLocation>();
                 // var productLocationResult = cnn.ProductLocationGetByLocation(GlobalContext.BranchCode, txtLocationCodeScan.Text, GlobalContext.WarehouseCode);
                 var productLocationResult = ServiceHelper.MobileServices.ProductLocationGetByLocation(GlobalContext.BranchCode, txtLocationCodeScan.Text, GlobalContext.WarehouseCode);
                 if (productLocationResult.Length >= 0)
                 {
                     productLocations.AddRange(productLocationResult);
                     //foreach (var item in productLocationResult)
                     //{
                     //    productLocations.Add(new ProductLocation
                     //                {
                     //                   BalanceQuantity = item.BalanceQuantity ,
                     //                   BalanceQuantitySpecified = item.BalanceQuantitySpecified,
                     //                    BalanceQuantityText = item.BalanceQuantityText,
                     //                     CreateDate = item.CreateDate,
                     //                      CreateDateSpecified = item.CreateDateSpecified,
                     //                       DisplayOrder = item.DisplayOrder,
                     //                        DisplayOrderSpecified = item.DisplayOrderSpecified,
                     //                         DocumentDate = item.DocumentDate,
                     //                          DocumentDateSpecified = item.DocumentDateSpecified,
                     //                           DocumentNo = item.DocumentNo,
                     //                            LocationCode = item.LocationCode,
                     //                             LocationStatus = item.LocationStatus,
                     //                              LocationType = item.LocationType,
                     //                               MaxStock = item.MaxStock,
                     //                                MaxStockSpecified = item.MaxStockSpecified,
                     //                                 OfficerID = item.OfficerID,
                     //                                  PriceStatus = item.PriceStatus,
                     //                                   ProductBarcode = item.ProductBarcode,
                     //                                    ProductCode = item.ProductCode,
                     //                                     ProductName = item.ProductName,
                     //                                      ProductUnitCode = item.ProductUnitCode,
                     //                                       ProductUnitName = item.ProductUnitName,
                     //                                        PutDeep = item.PutDeep,
                     //                                         PutDeepSpecified = item.PutDeepSpecified,
                     //                                          PutLevel = item.PutLevel,
                     //                                           PutLevelSpecified = item.PutLevelSpecified,
                     //                                            PutQuantity = item.PutQuantity,
                     //                                             PutQuantitySpecified = item.PutQuantitySpecified,
                     //                                              RandomText = item.RandomText,
                     //                                               Remark = item.Remark,
                     //                                                RequestPrintLabel = item.RequestPrintLabel,
                     //                                                 RequestPrintLabelSpecified = item.RequestPrintLabelSpecified,
                     //                                                  SalePrice = item.SalePrice,
                     //                                                   SalePriceSpecified = item.SalePriceSpecified,
                     //                                                    ShopPrice = item.ShopPrice,
                     //                                                     ShopPriceSpecified = item.ShopPriceSpecified,
                     //                                                      StatusText = item.StatusText,
                     //                                                       UserID = item.UserID,
                     //                                                        WarehouseCode = item.WarehouseCode,
                     //                                                         WarehouseName = item.WarehouseName
                     //                }
                     //               );
                     //}
                     bsLocation.DataSource = productLocations;
                     _currentRowIndex      = 0;
                     GridSelected();
                 }
             }
             else
             {
                 MessageBox.Show("ไม่พบตำแหน่งนี้ในระบบ");
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }