Beispiel #1
0
        public void bindgrid()
        {
            iInboundClient Inbound = new iInboundClient();

            try
            {
                CustomProfile profile = CustomProfile.GetProfile();
                DataSet       ds      = new DataSet();
                string        role    = profile.Personal.UserType.ToString();
                if (role == "Super Admin" || role == "Admin" || role == "Warehouse Admin")
                {
                    long userCompany = profile.Personal.CompanyID;
                    ds = Inbound.BindInboundGrid(userCompany, profile.DBConnection._constr);
                }
                else
                {
                    ds = Inbound.BindInboundGridbyUser(profile.Personal.UserID, profile.DBConnection._constr);
                }
                /*Temparary Change*/
                if (profile.Personal.CompanyID == 10237)
                {
                    hdnUsrCompany.Value = "1";
                    grdPurchaseOrder.Columns[8].Visible  = false;
                    grdPurchaseOrder.Columns[11].Visible = false;
                }
                /*Temparary Change*/
                grdPurchaseOrder.DataSource = ds;
                grdPurchaseOrder.DataBind();

                grdPurchaseOrder.AllowMultiRecordSelection = true;
                grdPurchaseOrder.AllowRecordSelection      = true;
            }
            catch { }
            finally { Inbound.Close(); }
        }
        public void GetLoaderDetail(long ldrID)
        {
            iInboundClient                 Inbound    = new iInboundClient();
            CustomProfile                  profile    = CustomProfile.GetProfile();
            iUCCommonFilterClient          objService = new iUCCommonFilterClient();
            List <vGetUserProfileByUserID> UsersList  = new List <vGetUserProfileByUserID>();

            try
            {
                tLoaderDetail LD = new tLoaderDetail();
                LD = Inbound.GetLoaderDetailOfGRN(ldrID, profile.DBConnection._constr);

                List <mVendor> VendorLst = new List <mVendor>();
                VendorLst = Inbound.GetVendor(profile.Personal.CompanyID, profile.DBConnection._constr).ToList();
                ddlLoaderName.DataSource = VendorLst;
                ddlLoaderName.DataBind();
                ddlLoaderName.SelectedIndex = ddlLoaderName.Items.IndexOf(ddlLoaderName.Items.FindByValue(LD.LoaderID.ToString()));

                txtInTime.Text     = LD.InTime.ToString();
                txtOutTime.Text    = LD.OutTime.ToString();
                txtBoxhandled.Text = LD.BoxHandels.ToString();
                txtRate.Text       = LD.RatePerBox.ToString();
                txtTotal.Text      = LD.Total.ToString();
            }
            catch (System.Exception ex) { Login.Profile.ErrorHandling(ex, "Loader.aspx", "GetLoaderDetail"); }
            finally { Inbound.Close(); }
        }
Beispiel #3
0
        protected void BindPOGrid(object sender, EventArgs e)
        {
            iInboundClient Inbound = new iInboundClient();

            try
            {
                CustomProfile profile = CustomProfile.GetProfile();
                DataSet       ds      = new DataSet();
                ds = Inbound.BindPIGrid(profile.DBConnection._constr);
                grdPutIn.DataSource = ds;
                grdPutIn.DataBind();
            }
            catch { }
            finally { Inbound.Close(); }

            //iPurchaseOrderClient Purchase = new iPurchaseOrderClient();
            //try
            //{

            //    DataSet ds = new DataSet();
            //    ds.Reset();
            //    ds = Purchase.ShowPurchaseOrder();
            //    Grid1.DataSource = ds;
            //    Grid1.DataBind();
            //}
            //catch (Exception ex)
            //{
            //}
            //finally
            //{
            //    Purchase.Close();
            //}
        }
 protected void RebindGrid(object sender, EventArgs e)
 {
     try
     {
         CustomProfile  profile = CustomProfile.GetProfile();
         iInboundClient Inbound = new iInboundClient();
         if (Session["QCID"] != null)
         {
             long qcId = long.Parse(Session["QCID"].ToString());
             grdLocationSearch.DataSource = Inbound.GetLocationForPutIn(grdLocationSearch.CurrentPageIndex, hdnFilterText.Value, qcId, profile.DBConnection._constr);
             grdLocationSearch.DataBind();
         }
         else if (Session["SOID"] != null)
         {
             long soId = long.Parse(Session["SOID"].ToString());
             //grdLocationSearch.DataSource = Inbound.GetLocationForPutIn(grdLocationSearch.CurrentPageIndex, hdnFilterText.Value, soId, profile.DBConnection._constr);
             grdLocationSearch.DataSource = Inbound.GetLocationForPickUP(grdLocationSearch.CurrentPageIndex, hdnFilterText.Value, soId, profile.DBConnection._constr);
             grdLocationSearch.DataBind();
         }
     }
     catch (System.Exception ex)
     {
         Login.Profile.ErrorHandling(ex, this, "LocationSearch.aspx.cs", "RebindGrid");
     }
 }
Beispiel #5
0
        public static int WMCancelOrder(long SelectedOrder)
        {
            iInboundClient Inbound = new iInboundClient();
            CustomProfile  profile = CustomProfile.GetProfile();
            long           UserID  = profile.Personal.UserID;
            int            result  = Inbound.CancelSelectedOrder(SelectedOrder, UserID, profile.DBConnection._constr);

            return(result);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            long asnID = long.Parse(Session["ASNID"].ToString());

            if (Session["ASNID"].ToString() != null)
            {
                CustomProfile  profile = CustomProfile.GetProfile();
                iInboundClient Inbound = new iInboundClient();
                gdASNSku.DataSource = Inbound.GetASNDetailByID(asnID, profile.DBConnection._constr);
                gdASNSku.DataBind();
            }
        }
        public void BindGrid()
        {
            iInboundClient Inbound = new iInboundClient();

            try
            {
                CustomProfile profile = CustomProfile.GetProfile();
                if (Session["QCID"] != null)
                {
                    //DataSet ds = new DataSet();
                    //ds =
                    if (Session["QCstate"].ToString() == "View")
                    {
                        GridReceipt.Columns[0].Visible = false;
                        long    qcID = long.Parse(Session["QCID"].ToString());
                        DataSet ds   = new DataSet();
                        ds = Inbound.GetSavedPutInListbyQCID(long.Parse(Session["QCID"].ToString()), profile.DBConnection._constr);
                        GridReceipt.DataSource = ds; // Inbound.GetSavedPutInListbyQCID(long.Parse(Session["QCID"].ToString()), profile.DBConnection._constr);
                        GridReceipt.DataBind();
                        hdnPutInNo.Value    = ds.Tables[0].Rows[0]["ID"].ToString();
                        BtnSequence.Visible = false; btnUnpacked.Visible = false;
                    }
                    else
                    {
                        GridReceipt.DataSource = Inbound.GetPutInList(Session["QCID"].ToString(), Session.SessionID, profile.Personal.UserID.ToString(), ObjectName, profile.DBConnection._constr);
                        GridReceipt.DataBind();
                        BtnSequence.Visible = true; btnUnpacked.Visible = true;
                    }
                }
                else if (Session["TRID"] != null)
                {
                    GridReceipt.DataSource = Inbound.GetPutInListByTRID(long.Parse(Session["TRID"].ToString()), Session.SessionID, profile.Personal.UserID.ToString(), ObjectName, profile.DBConnection._constr);
                    GridReceipt.DataBind();
                    if (Session["TRstate"].ToString() == "View")
                    {
                        BtnSequence.Visible = false; imgBtnEdit1.Visible = false; btnUnpacked.Visible = false;
                    }
                    else
                    {
                        BtnSequence.Visible = true; imgBtnEdit1.Visible = true; btnUnpacked.Visible = true;
                    }
                }
            }
            catch { }
            finally { Inbound.Close(); }
            //iReceivableClient ReceivableClient = new iReceivableClient();

            //DataSet ds = ReceivableClient.GetTempData();
            //GridReceipt.DataSource = ds;
            //GridReceipt.DataBind();
        }
        public void BindReturnGrid()
        {
            iInboundClient Inbound = new iInboundClient();

            try
            {
                CustomProfile profile = CustomProfile.GetProfile();
                DataSet       ds      = new DataSet();
                ds = Inbound.BindReturnGrid(profile.DBConnection._constr);
                grdReturn.DataSource = ds;
                grdReturn.DataBind();
            }
            catch { }
            finally { Inbound.Close(); }
        }
Beispiel #9
0
        public void BindGrid()
        {
            iInboundClient Inbound = new iInboundClient();

            try
            {
                CustomProfile profile   = CustomProfile.GetProfile();
                DataSet       ds        = new DataSet();
                long          CompanyID = profile.Personal.CompanyID;
                ds = Inbound.BindTransferGrid(CompanyID, profile.DBConnection._constr);
                grdTransfer.DataSource = ds;
                grdTransfer.DataBind();
            }
            catch { }
            finally { Inbound.Close(); }
        }
        public void GetASNDetail(long asnID)
        {
            iInboundClient                 Inbound    = new iInboundClient();
            CustomProfile                  profile    = CustomProfile.GetProfile();
            iUCCommonFilterClient          objService = new iUCCommonFilterClient();
            List <vGetUserProfileByUserID> UsersList  = new List <vGetUserProfileByUserID>();

            try
            {
                tASNHead ah = new tASNHead();
                ah = Inbound.GetAsnByAsnID(asnID, profile.DBConnection._constr);

                txtASNNumber.Text = ah.ASNNumber.ToString();
                UCASNDate.Date    = ah.ASNDate;

                UsersList = objService.GetUserListByWarehouseID(10013, profile.DBConnection._constr).ToList();
                UsersList = UsersList.Where(x => x.userID == profile.Personal.UserID).ToList();
                vGetUserProfileByUserID select = new vGetUserProfileByUserID()
                {
                    userID = 0, userName = "******"
                };
                UsersList.Insert(0, select);
                ddlASNBy.DataSource = UsersList;
                ddlASNBy.DataBind();
                ddlASNBy.SelectedIndex = ddlASNBy.Items.IndexOf(ddlASNBy.Items.FindByValue(ah.ASNEnteredBy.ToString()));

                List <mWarehouseMaster> WarehouseList = new List <mWarehouseMaster>();
                long UserID = profile.Personal.UserID;
                WarehouseList           = Inbound.GetUserWarehouse(UserID, profile.DBConnection._constr).ToList();
                ddlWarehouse.DataSource = WarehouseList;
                ddlWarehouse.DataBind();
                // ddlWarehouse.SelectedIndex = ddlWarehouse.Items.IndexOf(ddlWarehouse.Items.FindByValue(ah.WarehouseNo.ToString()));

                List <mVendor> VendorLst = new List <mVendor>();
                VendorLst            = Inbound.GetVendor(profile.Personal.CompanyID, profile.DBConnection._constr).ToList();
                ddlVendor.DataSource = VendorLst;
                ddlVendor.DataBind();
                //    ddlVendor.SelectedIndex = ddlVendor.Items.IndexOf(ddlVendor.Items.FindByValue(ah.VendorId.ToString()));

                txtRemark.Text = ah.Remark.ToString();

                Grid1.DataSource = Inbound.GetASNDetailByID(asnID, profile.DBConnection._constr);
                Grid1.DataBind();
            }
            catch (System.Exception ex) { Login.Profile.ErrorHandling(ex, "AsnDetail.aspx", "GetASNDetail"); }
            finally { Inbound.Close(); }
        }
Beispiel #11
0
        public static string WMSaveDebitNote(object objCNHead, long poID, long warehouseID)
        {
            long           dnhID   = 0;
            int            rslt    = 0;
            string         result  = "";
            iInboundClient Inbound = new iInboundClient();

            try
            {
                CustomProfile  profile = CustomProfile.GetProfile();
                tDebitNoteHead dh      = new tDebitNoteHead();
                //tCreditNoteHead ch = new tCreditNoteHead();
                Dictionary <string, object> d = new Dictionary <string, object>();
                d = (Dictionary <string, object>)objCNHead;
                if (HttpContext.Current.Session["GRNID"] != null)
                {
                    dh.ObjectName    = "PurchaseOrder";
                    dh.ONO           = Convert.ToInt64(d["ONO"]);
                    dh.Remark        = d["Remark"].ToString();
                    dh.DebitNoteDate = Convert.ToDateTime(d["DebitNoteDate"]);
                    dh.Total         = Convert.ToDecimal(d["Total"]);
                    dh.Company       = Convert.ToInt64(d["Company"]);
                    dh.CreatedBy     = profile.Personal.UserID;
                    dh.CreationDate  = DateTime.Now;

                    dnhID = Inbound.SaveIntotDebitNoteHead(dh, profile.DBConnection._constr);

                    if (dnhID > 0)
                    {
                        rslt = Inbound.SaveDebitNoteDetail(dnhID, poID, warehouseID, profile.DBConnection._constr);
                        if (rslt == 1)
                        {
                            result = "Credit Note saved successfully";
                        }
                        else
                        {
                            result = "Some error occurred";
                        }
                    }
                }
            }
            catch (System.Exception ex) { Login.Profile.ErrorHandling(ex, "CreditNote.aspx", "WMSaveCreditNote"); }
            finally { Inbound.Close(); }
            return(result);
        }
        public void BindGrid()
        {
            iInboundClient Inbound = new iInboundClient();

            try
            {
                CustomProfile profile   = CustomProfile.GetProfile();
                DataSet       ds        = new DataSet();
                long          CompanyID = profile.Personal.CompanyID;
                string        order     = Request.QueryString["inv"];
                if (order == "PO")
                {
                    grdQC.Columns[1].HeaderText = "GRN ID";
                    grdQC.Columns[5].HeaderText = "Vendor Name";
                    grdQC.Columns[11].Visible   = false;
                    grdQC.Columns[9].Visible    = true;
                    grdQC.Columns[10].Visible   = true;
                }
                else if (order == "SO")
                {
                    grdQC.Columns[1].HeaderText = "Pick Up ID";
                    grdQC.Columns[5].HeaderText = "Client Name";
                    grdQC.Columns[11].Visible   = true;
                    grdQC.Columns[9].Visible    = false;
                    grdQC.Columns[10].Visible   = false;
                }
                if (order == "PO")
                {
                    ds = Inbound.BindQCGrid(CompanyID, profile.DBConnection._constr);
                }
                else if (order == "SO")
                {
                    ds = Inbound.BindQCGridofSO(CompanyID, profile.DBConnection._constr);
                }
                grdQC.DataSource = ds;
                grdQC.DataBind();


                grdQC.AllowMultiRecordSelection = true;
                grdQC.AllowRecordSelection      = true;
            }
            catch { }
            finally { Inbound.Close(); }
        }
Beispiel #13
0
        public void GetPODetailsByGRNID(long grnID)
        {
            iInboundClient Inbound = new iInboundClient();

            try
            {
                CustomProfile profile = CustomProfile.GetProfile();
                long          poID = 0, warehouseID = 0;
                poID         = Inbound.GetPOIDFromGRNID(grnID, profile.DBConnection._constr); hdnSessionPONo.Value = poID.ToString();
                lblPONO.Text = poID.ToString();

                tPurchaseOrderHead PH = new tPurchaseOrderHead();
                PH          = Inbound.GetPoHeadByPOID(poID, profile.DBConnection._constr);
                warehouseID = long.Parse(PH.Warehouse.ToString()); hdnWarehouseID.Value = PH.Warehouse.ToString();
                long   CompanyID = long.Parse(PH.CompanyID.ToString()); hdnCompanyID.Value = PH.CompanyID.ToString();
                long   vendorID  = long.Parse(PH.VendorID.ToString());
                string vndrName  = Inbound.GetVendorNameByID(vendorID, profile.DBConnection._constr);
                lblVndrName.Text = vndrName.ToString();

                lblPODt.Text = PH.Creationdate.ToString();

                List <WMS_GetDebitNoteDetailByPOID_Result> partLst = new List <WMS_GetDebitNoteDetailByPOID_Result>();
                partLst = Inbound.GetDebitNotePartDetailByPOID(poID, warehouseID, profile.DBConnection._constr).ToList();
                grdSkuList.DataSource = partLst;
                grdSkuList.DataBind();

                decimal totAmt = Inbound.GetTotalofCreditNote(poID, warehouseID, profile.DBConnection._constr);
                lblTotal.Text = totAmt.ToString();

                DataSet ds = new DataSet();
                ds = Inbound.CheckDebitNote(poID, "PurchaseOrder", profile.DBConnection._constr);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    btnSaveCN.Visible = false;
                    txtRemark.Text    = ds.Tables[0].Rows[0]["Remark"].ToString();
                    UCDebitDate.Date  = Convert.ToDateTime(ds.Tables[0].Rows[0]["DebitNoteDate"].ToString());
                    txtRemark.Enabled = false;
                }
            }
            catch (System.Exception ex) { Login.Profile.ErrorHandling(ex, "DebitNote.aspx", "GetPODetailsByGRNID"); }
            finally { Inbound.Close(); }
        }
Beispiel #14
0
        public static int WMShowReport(string SelectedQC)
        {
            int            result  = 0;
            DataSet        ds      = new DataSet();
            CustomProfile  profile = CustomProfile.GetProfile();
            iInboundClient Inbound = new iInboundClient();

            try
            {
                Inbound.SetSelectedRecordToLabelPrintingStatus(SelectedQC, profile.DBConnection._constr);

                ds = Inbound.GetProductDetails(SelectedQC, profile.DBConnection._constr);
                ds.Tables[0].TableName = "DataSet1";
                HttpContext.Current.Session["ReportDS"]  = ds;
                HttpContext.Current.Session["SelObject"] = "LabelPrinting";
                result = Convert.ToInt16(ds.Tables[0].Rows.Count);
            }
            catch { }
            finally { Inbound.Close(); }
            return(result);
        }
Beispiel #15
0
        public void GetOrderDetailsByQCID(long qcID)
        {
            iInboundClient Inbound = new iInboundClient();

            try
            {
                CustomProfile       profile = CustomProfile.GetProfile();
                WMS_VW_GetQCDetails qcD     = new WMS_VW_GetQCDetails();
                qcD = Inbound.GetQCDetailsByQCID(qcID, profile.DBConnection._constr);
                string objectName = qcD.ObjectName.ToString();
                if (objectName == "PurchaseOrder")
                {
                    long grnid = long.Parse(qcD.OID.ToString());
                    GetPODetailsByGRNID(grnid);
                }
                else if (objectName == "SalesOrder")
                {
                }
            }
            catch (System.Exception ex) { Login.Profile.ErrorHandling(ex, "DebitNote.aspx", "GetOrderDetailsByQCID"); }
            finally { Inbound.Close(); }
        }
Beispiel #16
0
        public void BindGrid()
        {
            iInboundClient Inbound = new iInboundClient();

            try
            {
                CustomProfile profile = CustomProfile.GetProfile();
                DataSet       ds      = new DataSet();
                if (PreviousPOID != 0)
                {
                    if (Session["POID"] != null)
                    {
                        ds = Inbound.BindGRNGridofSelectedPO(long.Parse(Session["POID"].ToString()), profile.DBConnection._constr);
                    }
                    else if (Session["SOID"] != null)
                    {
                        ds = Inbound.BindGRNGridofSelectedPO(long.Parse(Session["SOID"].ToString()), profile.DBConnection._constr);
                    }
                }
                else
                {
                    string role = profile.Personal.UserType.ToString();
                    if (role == "Super Admin" || role == "Admin" || role == "Warehouse Admin")
                    {
                        long userCompany = profile.Personal.CompanyID;
                        ds = Inbound.BindGRNGrid(userCompany, profile.DBConnection._constr);
                    }
                    else
                    {
                        ds = Inbound.BindGRNGridUserWise(profile.Personal.UserID, profile.DBConnection._constr);
                    }
                }

                grdGRN.DataSource = ds;
                grdGRN.DataBind();
            }
            catch { }
            finally { Inbound.Close(); }
        }
Beispiel #17
0
        public static int WMCheckStatus(string SelectedGRN)
        {
            int            Result  = 0;
            iInboundClient Inbound = new iInboundClient();

            try
            {
                CustomProfile profile   = CustomProfile.GetProfile();
                bool          exeresult = Inbound.CheckJobCardofSelectedRecord(SelectedGRN, "GRN", profile.DBConnection._constr);
                if (exeresult == true)
                {
                    Result = Inbound.CheckSelectedGRNStatusIsSameOrNot(SelectedGRN, profile.DBConnection._constr);
                    Page objp = new Page();
                    objp.Session["SelectedRec"] = SelectedGRN; objp.Session["ObjectName"] = "GRN";
                }
                else
                {
                    Result = 0;
                }
            }
            catch { }
            finally { Inbound.Close(); }
            return(Result);
        }
Beispiel #18
0
        public void BindGrid()
        {
            iInboundClient Inbound = new iInboundClient();

            try
            {
                CustomProfile profile   = CustomProfile.GetProfile();
                DataSet       ds        = new DataSet();
                long          CompanyID = profile.Personal.CompanyID;
                long          GRNID     = long.Parse(Request.QueryString["ID"].ToString());
                if (GRNID == 0)
                {
                    ds = Inbound.BindQCGrid(CompanyID, profile.DBConnection._constr);
                }
                else
                {
                    ds = Inbound.BindQCGridofSelectedGRN(GRNID, profile.DBConnection._constr);
                }
                grdLabelPrint.DataSource = ds;
                grdLabelPrint.DataBind();
            }
            catch { }
            finally { Inbound.Close(); }
        }
Beispiel #19
0
        public void ProcessRequest(HttpContext context)
        {
            SqlConnection conn = new SqlConnection(strcon);

            context.Response.ContentType = "text/plain";
            String jsonString = String.Empty;

            jsonString = "{\n\"save_qc\": [\n";
            try
            {
                long           uid           = long.Parse(context.Request.QueryString["userid"]);
                long           oid           = long.Parse(context.Request.QueryString["oid"]);
                string         objectname    = context.Request.QueryString["objectname"];
                string         productdetail = context.Request.QueryString["productdetail"];
                string         remark        = context.Request.QueryString["remark"];
                string         userName      = GetUserID(uid);
                CustomProfile  profile       = CustomProfile.GetProfile(userName);
                iInboundClient Inbound       = new iInboundClient();
                int            count1        = Workflow(profile.Personal.CompanyID, profile.Personal.CustomerId, objectname);
                long           status        = 0;
                if (count1 > 0)
                {
                    status = getStatus(objectname);
                }
                else
                {
                    status = 33;
                }
                long   CustomerID, CompanyID, reasonid;
                string lottable1;
                string lot1 = "", lot2 = "", lot3 = "";
                long   QCID = 0;
                /* QualityControlHead */
                tQualityControlHead QCHead = new tQualityControlHead();
                QCHead.ObjectName   = objectname;
                QCHead.OID          = oid;
                QCHead.QCDate       = DateTime.Now;
                QCHead.QCBy         = uid;
                QCHead.Remark       = remark;
                QCHead.CreatedBy    = uid;
                QCHead.Creationdate = DateTime.Now;
                QCHead.Status       = status;
                QCHead.Company      = profile.Personal.CompanyID;
                QCHead.CustomerID   = profile.Personal.CustomerId;
                DataTable dtnew = new DataTable();
                dtnew = GetDatatableDetails(" select * from tQualityControlHead where oid=" + oid + "");
                if (dtnew.Rows.Count > 0)
                {
                    QCID = Convert.ToInt64(dtnew.Rows[0]["ID"].ToString());
                }
                else
                {
                    QCID = Inbound.SavetQualityControlHead(QCHead, profile.DBConnection._constr);
                }

                /* QualityControlDetail */

                SqlCommand     cmd1 = new SqlCommand();
                SqlDataAdapter da1  = new SqlDataAdapter();
                DataSet        ds1  = new DataSet();
                cmd1.CommandType = CommandType.Text;
                cmd1.CommandText = "select * from  SplitString('" + productdetail + "','@')";
                cmd1.Connection  = conn;
                cmd1.Parameters.Clear();
                da1.SelectCommand = cmd1;
                da1.Fill(ds1, "tbl1");
                int cntr1 = 0;
                cntr1 = ds1.Tables[0].Rows.Count;
                if (ds1.Tables[0].Rows.Count > 0)
                {
                    for (int p = 0; p <= cntr1 - 1; p++)
                    {
                        string  prdString, qtystring; long prdID, oqty, uomid;
                        decimal qty = 0, grnqty = 0, qcqty = 0, rejectqty = 0;
                        string  lot1str, lot2str, lot3str, serialno, lot4str, lot5str, lot6str;
                        string  mygrnPrdString = "select * from SplitString('" + ds1.Tables[0].Rows[p]["part"].ToString() + "','|')";
                        ds.Clear();
                        dt.Clear();
                        cmd.CommandType = CommandType.Text;
                        cmd.CommandText = mygrnPrdString;
                        cmd.Connection  = conn;
                        cmd.Parameters.Clear();
                        da.SelectCommand = cmd;
                        da.Fill(ds, "tbl1");
                        dt = ds.Tables[0];
                        int cntr = dt.Rows.Count;
                        if (cntr > 0)
                        {
                            for (int i = 0; i <= cntr - 1; i++)
                            {
                                //     ID QCID    ProdID OQty    GRNQty QCQty   RejectedQty ExcessQty   Status Reason  Company CustomerID  UOMID PackingStyle    ReasonID

                                //ProdID
                                prdString = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                                string[] spltprdString = prdString.Split(':');
                                prdID = long.Parse(spltprdString[1]);
                                i     = i + 1;

                                //qty=OQty
                                qtystring = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                                string[] spltqty = qtystring.Split(':');
                                qty = decimal.Parse(spltqty[1]);
                                i   = i + 1;

                                //GRNqty
                                DataSet dsqty = new DataSet();
                                // dsqty = GetAllDetails(oid, prdID, objectname);
                                grnqty = GetQtyAllDetails(oid, prdID, objectname);
                                // grnqty = decimal.Parse(dsqty.Tables[0].Rows[0]["GRNQty"].ToString());


                                //QCQTY=acceptedqty
                                lot1str = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                                string[] lotsplit = lot1str.Split(':');
                                qcqty = decimal.Parse(lotsplit[1]);
                                i     = i + 1;

                                //RejectedQty=rejectedqty
                                lot2str = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                                string[] lot2split = lot2str.Split(':');
                                rejectqty = decimal.Parse(lot2split[1]);
                                i         = i + 1;

                                //reasoncode=ReasonID
                                lot3str = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                                string[] lot3split = lot3str.Split(':');
                                reasonid = long.Parse(lot3split[1]);

                                //serial number if avaliable
                                if (cntr > 5)
                                {
                                    i       = i + 1;
                                    lot4str = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                                    string[] lotsplit4 = lot4str.Split(':');
                                    lot1 = lotsplit4[1];
                                }
                                if (cntr > 6)
                                {
                                    i       = i + 1;
                                    lot5str = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                                    string[] lotsplit4 = lot5str.Split(':');
                                    lot2 = lotsplit4[1];
                                }
                                if (cntr > 7)
                                {
                                    i       = i + 1;
                                    lot6str = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                                    string[] lotsplit4 = lot6str.Split(':');
                                    lot3 = lotsplit4[1];
                                }


                                DataSet dsOrder = new DataSet();
                                dsOrder = GetUOMofPrd(oid, objectname, prdID);
                                decimal poqty = 0;
                                long    UOMID = long.Parse(dsOrder.Tables[0].Rows[0]["UOMID"].ToString());
                                //long UOMID = 16;
                                SqlCommand     cmdDetail = new SqlCommand();
                                SqlDataAdapter daDetail  = new SqlDataAdapter();
                                DataSet        dsDetail  = new DataSet();
                                DataTable      dtDetail  = new DataTable();;
                                cmdDetail.CommandType = CommandType.StoredProcedure;
                                cmdDetail.CommandText = "SP_MobileInsertQCDetails";
                                cmdDetail.Connection  = conn;
                                cmdDetail.Parameters.Clear();
                                cmdDetail.Parameters.AddWithValue("QCID", QCID);
                                cmdDetail.Parameters.AddWithValue("ProdID", prdID);
                                cmdDetail.Parameters.AddWithValue("OQty", qty);
                                cmdDetail.Parameters.AddWithValue("GRNQty", grnqty);
                                cmdDetail.Parameters.AddWithValue("QCQty", qcqty);
                                cmdDetail.Parameters.AddWithValue("RejectedQty", rejectqty);
                                cmdDetail.Parameters.AddWithValue("UOMID", UOMID);
                                cmdDetail.Parameters.AddWithValue("ReasonID", reasonid);
                                cmdDetail.Connection.Open();
                                cmdDetail.ExecuteNonQuery();
                                cmdDetail.Connection.Close();
                                SaveQCLottable(lot1, profile.Personal.CompanyID, profile.Personal.CustomerId, prdID, QCID, lot2, lot3);
                            }
                        }
                    }
                    //Upadte status from tgrnhead and tpurchasehead
                    int count = 0;
                    count = Workflow(profile.Personal.CompanyID, profile.Personal.CustomerId, objectname);
                    if (count > 0)
                    {
                        RecordUpdateStatus(oid, 32, objectname);
                    }
                    else
                    {
                        RecordUpdateStatus(oid, 33, objectname);
                    }

                    jsonString = jsonString + "{\n";
                    jsonString = jsonString + "\"status\": \"success\"\n";
                    jsonString = jsonString + "}\n";
                    jsonString = jsonString + "]\n}";
                    context.Response.Write(jsonString);
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
                jsonString = jsonString + "{\n";
                jsonString = jsonString + "\"status\": \"failed\"\n";
                jsonString = jsonString + "}\n";
                jsonString = jsonString + "]\n}";
                context.Response.Write(jsonString);
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            SqlConnection conn  = new SqlConnection(strcon);
            long          GRNID = 0;

            try
            {
                DateTime shippingdate         = DateTime.Now;
                DateTime expecteddeliverydate = DateTime.Now;
                if (context.Request.QueryString["userid"] != null)
                {
                    UserID = long.Parse(context.Request.QueryString["userid"]);
                }
                else if (context.Request.Form["userid"] != null)
                {
                    UserID = long.Parse(context.Request.Form["userid"]);
                }
                if (context.Request.QueryString["oid"] != null)
                {
                    orderID = long.Parse(context.Request.QueryString["oid"]);
                }
                else if (context.Request.Form["oid"] != null)
                {
                    orderID = long.Parse(context.Request.Form["oid"]);
                }
                if (context.Request.QueryString["objectname"] != null)
                {
                    objname = context.Request.QueryString["objectname"];
                }
                else if (context.Request.Form["objectname"] != null)
                {
                    objname = context.Request.Form["objectname"];
                }
                if (context.Request.QueryString["batchcode"] != null)
                {
                    batchcode = context.Request.QueryString["batchcode"];
                }
                else if (context.Request.Form["batchcode"] != null)
                {
                    batchcode = context.Request.Form["batchcode"];
                }
                if (context.Request.QueryString["remark"] != null)
                {
                    remark = context.Request.QueryString["remark"];
                }
                else if (context.Request.Form["remark"] != null)
                {
                    remark = context.Request.Form["remark"];
                }
                if (context.Request.QueryString["airwaybill"] != null)
                {
                    airwaybill = context.Request.QueryString["airwaybill"];
                }
                else if (context.Request.Form["airwaybill"] != null)
                {
                    airwaybill = context.Request.Form["airwaybill"];
                }
                if (context.Request.QueryString["shippingtype"] != null)
                {
                    shippingtype = context.Request.QueryString["shippingtype"];
                }
                else if (context.Request.Form["shippingtype"] != null)
                {
                    shippingtype = context.Request.Form["shippingtype"];
                }

                if (context.Request.QueryString["shippingdate"] != null)
                {
                    if (Convert.ToString(context.Request.QueryString["shippingdate"]) == "N/A")
                    {
                    }
                    else
                    {
                        shippingdate = Convert.ToDateTime(context.Request.QueryString["shippingdate"]);
                    }
                }
                else if (context.Request.Form["shippingdate"] != null)
                {
                    if (context.Request.Form["shippingdate"] == "N/A")
                    {
                    }
                    else
                    {
                        shippingdate = Convert.ToDateTime(context.Request.Form["shippingdate"]);
                    }
                }

                if (context.Request.QueryString["expecteddeliverydate"] != null)
                {
                    if (Convert.ToString(context.Request.QueryString["expecteddeliverydate"]) == "N/A")
                    {
                    }
                    else
                    {
                        expecteddeliverydate = Convert.ToDateTime(context.Request.QueryString["expecteddeliverydate"]);
                    }
                }
                else if (context.Request.Form["expecteddeliverydate"] != null)
                {
                    if (context.Request.Form["expecteddeliverydate"] == "N/A")
                    {
                    }
                    else
                    {
                        expecteddeliverydate = Convert.ToDateTime(context.Request.Form["expecteddeliverydate"]);
                    }
                }
                if (context.Request.QueryString["dockno"] != null)
                {
                    dockno = context.Request.QueryString["dockno"];
                }
                else if (context.Request.Form["dockno"] != null)
                {
                    dockno = context.Request.Form["dockno"];
                }
                if (context.Request.QueryString["lrno"] != null)
                {
                    lrno = context.Request.QueryString["lrno"];
                }
                else if (context.Request.Form["lrno"] != null)
                {
                    lrno = context.Request.Form["lrno"];
                }
                if (context.Request.QueryString["intime"] != null)
                {
                    intime = context.Request.QueryString["intime"];
                }
                else if (context.Request.Form["intime"] != null)
                {
                    intime = context.Request.Form["intime"];
                }
                if (context.Request.QueryString["outtime"] != null)
                {
                    outtime = context.Request.QueryString["outtime"];
                }
                else if (context.Request.Form["outtime"] != null)
                {
                    outtime = context.Request.Form["outtime"];
                }
                if (context.Request.QueryString["other"] != null)
                {
                    udr = context.Request.QueryString["other"];
                }
                else if (context.Request.Form["other"] != null)
                {
                    udr = context.Request.Form["other"];
                }

                context.Response.ContentType = "text/plain";
                String jsonString = String.Empty;
                jsonString = "{\n";   /*json Loop Start*/
                jsonString = jsonString + "\"result\":[{\n";

                iInboundClient Inbound      = new iInboundClient();
                string         userName     = GetUserID(UserID);
                CustomProfile  profile      = CustomProfile.GetProfile(userName);
                DataSet        dsUserDetail = new DataSet();
                dsUserDetail = GetUserDetails(UserID);
                CompanyID    = long.Parse(dsUserDetail.Tables[0].Rows[0]["CompanyID"].ToString());
                CustomerID   = long.Parse(dsUserDetail.Tables[0].Rows[0]["CustomerID"].ToString());
                tGRNHead GRNHead = new tGRNHead();
                GRNHead.ObjectName   = objname;
                GRNHead.OID          = orderID;
                GRNHead.GRNDate      = DateTime.Now;
                GRNHead.ReceivedBy   = UserID;
                GRNHead.CreatedBy    = UserID;
                GRNHead.Creationdate = DateTime.Now;
                GRNHead.CustomerID   = CustomerID;
                GRNHead.CompanyID    = CompanyID;
                string WorkFlow = "", NextObject = "";
                int    count = 0;
                if (objname == "PurchaseOrder")
                {
                    WorkFlow   = "Inbound";
                    NextObject = "QC";
                }
                if (objname == "Transfer")
                {
                    WorkFlow   = "Transfer";
                    NextObject = "QC";
                }
                if (objname == "SalesReturn")
                {
                    WorkFlow   = "Return";
                    NextObject = "QC";
                }
                count = GetWorkFlow(profile.Personal.CompanyID, profile.Personal.CustomerId, WorkFlow, NextObject, profile.DBConnection._constr);
                if (objname == "PurchaseOrder")
                {
                    if (count == 0)
                    {
                        GRNHead.Status = 33;
                    }
                    else
                    {
                        GRNHead.Status = 31;
                    }
                }
                if (objname == "Transfer")
                {
                    if (count == 0)
                    {
                        GRNHead.Status = 71;
                    }
                    else
                    {
                        GRNHead.Status = 60;
                    }
                }
                if (objname == "SalesReturn")
                {
                    if (count == 0)
                    {
                        GRNHead.Status = 53;
                    }
                    else
                    {
                        GRNHead.Status = 52;
                    }
                }
                GRNHead.OrderFrom = "Mobile";
                GRNHead.ShipID    = "";
                if (remark == "N/A")
                {
                    remark = "";
                }
                GRNHead.Remark = remark;
                if (airwaybill == "N/A")
                {
                    airwaybill = "";
                }
                GRNHead.AirwayBill = airwaybill;
                if (shippingtype == "N/A")
                {
                    shippingtype = "";
                }
                GRNHead.ShippingType      = shippingtype;
                GRNHead.ShippingDate      = shippingdate;
                GRNHead.TransporterRemark = "";
                if (lrno == "N/A")
                {
                    lrno = "";
                }
                GRNHead.LRNo = lrno;
                if (intime == "N/A")
                {
                    intime = "";
                }
                GRNHead.InTime = intime;
                if (outtime == "N/A")
                {
                    outtime = "";
                }
                GRNHead.OutTime         = outtime;
                GRNHead.ExpDeliveryDate = expecteddeliverydate;
                GRNHead.IsRead          = false;
                GRNHead.Other           = udr;
                GRNHead.IsGRN           = 1;
                DataTable dtgrn = new DataTable();
                dtgrn = GetGRNStatus(orderID, objname, UserID);
                if (dtgrn.Rows.Count > 0)
                {
                    batchcode = dtgrn.Rows[0]["BatchNo"].ToString();
                    GRNID     = Convert.ToInt64(dtgrn.Rows[0]["ID"]);
                }
                GRNHead.ID      = GRNID;
                GRNHead.BatchNo = batchcode;
                UpdateRemQty(orderID, objname);
                GRNID = Inbound.SavetGRNHead(GRNHead, profile.DBConnection._constr);
                if (GRNID > 0)
                {
                    jsonString = jsonString + "\"status\": \"success\",\n";
                    jsonString = jsonString + "\"reason\": \"\"\n";
                }
                else
                {
                    jsonString = jsonString + "\"status\": \"failed\",\n";
                    jsonString = jsonString + "\"reason\": \"Server error occured\"\n";
                }
                jsonString = jsonString + "}]\n";
                jsonString = jsonString + "}\n"; /*json Loop End*/
                context.Response.Write(jsonString);
            }
            catch (Exception ex)
            { Login.Profile.ErrorHandling(ex, "grn_save_grn", "ProcessRequest"); }
            finally
            { }
        }
Beispiel #21
0
        public void ProcessRequest(HttpContext context)
        {
            SqlConnection conn    = new SqlConnection(strcon);
            long          orderID = long.Parse(context.Request.Form["oid"]);
            long          uid     = long.Parse(context.Request.Form["uid"]);

            objectname = context.Request.Form["objname"].ToString();
            string          WorkFlow = "Outbound";
            string          NextObject = "QC";
            long            sequence = 0, prdID = 0;
            decimal         qty = 0;
            string          lCode = "", batchCode = "";
            string          lot1str = "", lot2str = "", lot3str = "", lot1 = "", lot2 = "", lot3 = "";
            string          prdString, qtystring, loccode, pid, bcode;
            int             rslt     = 0;
            long            pkupID   = 0;
            string          objNM    = "";
            string          userName = GetUserID(uid);
            CustomProfile   profile  = CustomProfile.GetProfile(userName);
            iOutboundClient Outbound = new iOutboundClient();

            /*First Save PickUp List Data in Temparary Table start*/
            List <WMS_SP_PickUpList_Result> pickupLst = new List <WMS_SP_PickUpList_Result>();
            // pickupLst = Outbound.GetPickUpList(orderID.ToString(), "", HttpContext.Current.Session.SessionID, uid.ToString(), "PickUp", profile.DBConnection._constr).ToList();
            //pickupLst = Outbound.GetPickUpList(orderID.ToString(), "", context.Session.SessionID, uid.ToString(), "PickUp", profile.DBConnection._constr).ToList();
            /*First Save PickUp List Data in Temparary Table start*/
            long           wid          = long.Parse(context.Request.Form["wid"]);
            string         putinDetails = context.Request.Form["putinDetails"];
            SqlCommand     cmd1         = new SqlCommand();
            SqlDataAdapter da1          = new SqlDataAdapter();
            DataSet        ds1          = new DataSet();

            cmd1.CommandType = CommandType.Text;
            cmd1.CommandText = "select * from  SplitString('" + putinDetails + "','@')";
            cmd1.Connection  = conn;
            cmd1.Parameters.Clear();
            da1.SelectCommand = cmd1;
            da1.Fill(ds1, "tbl1");
            int cntr1 = 0;

            cntr1 = ds1.Tables[0].Rows.Count;
            if (ds1.Tables[0].Rows.Count > 0)
            {
                for (int p = 0; p <= cntr1 - 1; p++)
                {
                    string myputinstring = "select * from  SplitString('" + ds1.Tables[0].Rows[p]["part"].ToString() + "','|')";
                    ds.Clear();
                    dt.Clear();
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = myputinstring;
                    cmd.Connection  = conn;
                    cmd.Parameters.Clear();
                    da.SelectCommand = cmd;
                    da.Fill(ds, "tbl1");
                    dt = ds.Tables[0];
                    int cntr = dt.Rows.Count;
                    if (cntr > 0)
                    {
                        for (int i = 0; i <= cntr - 1; i++)
                        {
                            //sequence
                            prdString = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                            string[] spltprdString = prdString.Split(':');
                            sequence = long.Parse(spltprdString[1]);
                            i        = i + 1;

                            //qty
                            qtystring = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                            string[] spltqty = qtystring.Split(':');
                            qty = decimal.Parse(spltqty[1]);
                            i   = i + 1;

                            //lcode
                            loccode = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                            string[] lotsplit = loccode.Split(':');
                            lCode = Convert.ToString(lotsplit[1]);
                            i     = i + 1;
                            GetLocationDetails(lCode, wid);
                            /*Get Location Details*/

                            //Prodid
                            pid = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                            string[] lotsplit1 = pid.Split(':');
                            prdID = long.Parse(lotsplit1[1]);
                            i     = i + 1;

                            //batch code
                            bcode = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                            string[] lotsplit2 = bcode.Split(':');
                            batchCode = Convert.ToString(lotsplit2[1]);
                            // i = i + 1;


                            /*Update List Qty Start*/
                            WMS_SP_PickUpList_Result pkupLst = new WMS_SP_PickUpList_Result();
                            pkupLst.Sequence = sequence;
                            pkupLst.LocQty   = qty;
                            // Outbound.UpdatePkupLstLocofSelRow(HttpContext.Current.Session.SessionID, "PickUp", uid.ToString(), pkupLst, profile.DBConnection._constr);
                            //Outbound.UpdatePickUPLstQtyofSelRow(HttpContext.Current.Session.SessionID, "PickUp", uid.ToString(), pkupLst, profile.DBConnection._constr);
                            /*Update List Qty End*/

                            /*Update List Location Details Start*/
                            WMS_SP_PickUpList_Result pkLst = new WMS_SP_PickUpList_Result();
                            pkLst.Sequence         = sequence;
                            pkLst.LocationID       = locationID;
                            pkLst.Code             = lCode;
                            pkLst.SortCode         = sortCode;
                            pkLst.Capacity         = capacity;
                            pkLst.AvailableBalance = avlBlnce;
                            // Outbound.UpdatePkupLstLocofSelRow(HttpContext.Current.Session.SessionID, "PickUp", uid.ToString(), pkLst, profile.DBConnection._constr);
                            //Outbound.UpdatePickUPLstQtyofSelRow(HttpContext.Current.Session.SessionID, "PickUp", uid.ToString(), pkLst, profile.DBConnection._constr);
                            /*Update List Location Details End*/

                            //serial number if avaliable
                            if (cntr >= 6)
                            {
                                i       = i + 1;
                                lot1str = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                                string[] lotsplit4 = lot1str.Split(':');
                                lot1 = lotsplit4[1];
                            }
                            if (cntr >= 7)
                            {
                                i       = i + 1;
                                lot2str = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                                string[] lot2split = lot2str.Split(':');
                                lot2 = lot2split[1];
                            }
                            if (cntr >= 8)
                            {
                                i       = i + 1;
                                lot3str = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                                string[] lot3split = lot3str.Split(':');
                                lot3 = lot3split[1];
                            }

                            //string objNM = "";

                            DataTable dtobjnm = new DataTable();
                            dtobjnm = GetDatatableDetails("select Object as Objectname from tOrderHead where id=" + orderID + " union all select Objectname from tTransferHead where id=" + orderID + "");
                            objNM   = dtobjnm.Rows[0]["ObjectName"].ToString();

                            tPickUpHead ph = new tPickUpHead();
                            //ph.ObjectName = "SalesOrder";
                            ph.ObjectName   = objectname;
                            ph.OID          = orderID;
                            ph.PickUpDate   = DateTime.Now;
                            ph.PickUpBy     = uid;
                            ph.CreatedBy    = uid;
                            ph.CreationDate = DateTime.Now;
                            int countnew = GetWorkFlow(profile.Personal.CompanyID, profile.Personal.CustomerId, WorkFlow, NextObject, profile.DBConnection._constr);
                            if (countnew > 0)
                            {
                                if (objectname == "SalesOrder")
                                {
                                    ph.Status = 38;
                                }
                                else if (objectname == "Transfer")
                                {
                                    ph.Status = 57;
                                }
                            }
                            else
                            {
                                if (objectname == "SalesOrder")
                                {
                                    ph.Status = 32;
                                }
                                else if (objectname == "Transfer")
                                {
                                    ph.Status = 58;
                                }
                            }
                            //if (objectname == "SalesOrder")
                            //{
                            //    ph.Status = 38;
                            //}
                            // else if(objectname == "Transfer")
                            //{
                            //    ph.Status = 57;
                            //}
                            ph.CompanyID    = profile.Personal.CompanyID;
                            ph.CustomerID   = profile.Personal.CustomerId;
                            ph.PickUpStatus = true;
                            // DataTable dtnew = new DataTable();
                            //   dtnew = GetDatatableDetails("select * from tPutInHead where oid=" + orderID + "");
                            //if (objectname == "SalesOrder")
                            //{
                            //    dtnew = GetDatatableDetails("select * from tPickUpHead where oid=" + orderID + " and Status=32");
                            //}
                            //else if (objectname == "Transfer")
                            //{
                            //    dtnew = GetDatatableDetails("select * from tPickUpHead where oid=" + orderID + " and Status=58");
                            //}

                            //if (dtnew.Rows.Count > 0)
                            //{
                            //    pkupID = Convert.ToInt64(dtnew.Rows[0]["id"].ToString());
                            //}
                            //else
                            //{
                            //    pkupID = Outbound.SavetPickUpHead(ph, profile.DBConnection._constr);
                            //}
                            if (pkupID == 0)
                            {
                                pkupID = Outbound.SavetPickUpHead(ph, profile.DBConnection._constr);
                            }
                            if (pkupID > 0)
                            {
                                // rslt = Outbound.FinalSavePickUpDetail(orderID, HttpContext.Current.Session.SessionID, "PickUp", pkupID, uid.ToString(), Convert.ToInt32(ph.Status), profile.DBConnection._constr);
                                rslt = SavePickUpDetail(pkupID, prdID, qty, locationID, orderID, batchCode);
                            }

                            SavePickUpLottable(prdID, batchCode, locationID, qty, profile.Personal.CompanyID, profile.Personal.CustomerId, profile.Personal.UserID, lot1, lot2, lot3, pkupID);
                        }
                    }
                }
            }

            if (pkupID > 0)
            {
                // SaveInSkutransction();
                // INSERT INTO tskutransaction(skuid, batchcode, locationid, transtype, inqty, outqty, closingbalance, companyid, cutomerid, createdby, creationdate, lottable1, lottable2, lottable3)
                //SELECT tpd.Prodid,tpd.batchcode, tpd.locationid, 'Outbound',0,tpd.pickupqty,0,tph.companyid,tph.cutomerid,user,getdate(),
                //FROM tpickupdetail tpd left outer join tpickuphead tph on tpd.pickupid = tph.id
                //WHERE tph.id =
                iInboundClient Inbound = new iInboundClient();
                int            count   = 0;
                long           QCID    = 0;
                if (objectname == "SalesOrder")
                {
                    WorkFlow   = "Outbound";
                    NextObject = "QC";
                }
                if (objectname == "Transfer")
                {
                    WorkFlow   = "Transfer";
                    NextObject = "QCOut";
                }
                count = GetWorkFlow(profile.Personal.CompanyID, profile.Personal.CustomerId, WorkFlow, NextObject, profile.DBConnection._constr);
                if (count == 0)
                {
                    WMSOutbound.tQualityControlHead QCHead = new WMSOutbound.tQualityControlHead();
                    QCHead.CreatedBy    = profile.Personal.UserID;
                    QCHead.Creationdate = DateTime.Now;
                    // QCHead.ObjectName = "SalesOrder";
                    QCHead.ObjectName = objectname;
                    QCHead.OID        = pkupID;
                    QCHead.QCDate     = DateTime.Now;
                    QCHead.QCBy       = profile.Personal.UserID;
                    QCHead.Remark     = "";

                    if (objectname == "SalesOrder")
                    {
                        QCHead.Status = 32;
                    }
                    else if (objectname == "Transfer")
                    {
                        QCHead.Status = 58;
                    }
                    //QCHead.Status = 32;

                    QCHead.Company    = profile.Personal.CompanyID;
                    QCHead.CustomerID = profile.Personal.CustomerId;
                    QCID = Inbound.SavetQualityControlHead(QCHead, profile.DBConnection._constr);
                    if (QCID > 0)
                    {
                        DataSet dsQC = new DataSet();
                        dsQC = GetPickUpCount(pkupID, profile.DBConnection._constr);
                        if (dsQC.Tables[0].Rows.Count > 0)
                        {
                            for (int i = 0; i < dsQC.Tables[0].Rows.Count; i++)
                            {
                                long prodid = Convert.ToInt64(dsQC.Tables[0].Rows[i]["ProdID"]);
                                long qtynew = Convert.ToInt64(dsQC.Tables[0].Rows[i]["PickUpQty"]);
                                long uom    = Convert.ToInt64(dsQC.Tables[0].Rows[i]["UOMID"]);
                                //int RSLT1 = Inbound.FillQCDetail(QCID, PkUpID, profile.DBConnection._constr);
                                int RSLT1 = FillQCDetailNew(QCID, pkupID, prodid, qtynew, uom, profile.DBConnection._constr);
                            }
                        }
                    }
                    //update torderhead table
                    UpdateStatustorderhead(orderID);
                }
            }

            String xmlString = String.Empty;

            context.Response.ContentType = "text/plain";
            String jsonString = String.Empty;

            jsonString = "{\n\"resultlist\": [\n";   /*json Loop Start*/
            if (rslt > 0)
            {
                jsonString = jsonString + "{\n\"status\":\"success\"\n}\n";
            }
            else if (rslt == 0)
            {
                jsonString = jsonString + "{\n\"status\":\"failed\"\n}\n";
            }
            jsonString = jsonString + "]\n}";  /*json Loop End*/
            context.Response.Write(jsonString);
        }
        public void ProcessRequest(HttpContext context)
        {
            SqlConnection conn  = new SqlConnection(strcon);
            long          GRNID = 0;

            context.Response.ContentType = "text/plain";
            String jsonString = String.Empty;

            jsonString = "{\n\"save_grn\": [\n";

            try
            {
                DateTime shippingdate         = DateTime.Now;
                DateTime expecteddeliverydate = DateTime.Now;
                if (context.Request.QueryString["userid"] != null)
                {
                    uid = long.Parse(context.Request.QueryString["userid"]);
                }
                else if (context.Request.Form["userid"] != null)
                {
                    uid = long.Parse(context.Request.Form["userid"]);
                }
                if (context.Request.QueryString["oid"] != null)
                {
                    oid = long.Parse(context.Request.QueryString["oid"]);
                }
                else if (context.Request.Form["oid"] != null)
                {
                    oid = long.Parse(context.Request.Form["oid"]);
                }
                if (context.Request.QueryString["objectname"] != null)
                {
                    objectname = context.Request.QueryString["objectname"];
                }
                else if (context.Request.Form["objectname"] != null)
                {
                    objectname = context.Request.Form["objectname"];
                }
                if (context.Request.QueryString["batchcode"] != null)
                {
                    batchcode = context.Request.QueryString["batchcode"];
                }
                else if (context.Request.Form["batchcode"] != null)
                {
                    batchcode = context.Request.Form["batchcode"];
                }
                if (context.Request.QueryString["remark"] != null)
                {
                    remark = context.Request.QueryString["remark"];
                }
                else if (context.Request.Form["remark"] != null)
                {
                    remark = context.Request.Form["remark"];
                }
                if (context.Request.QueryString["airwaybill"] != null)
                {
                    airwaybill = context.Request.QueryString["airwaybill"];
                }
                else if (context.Request.Form["airwaybill"] != null)
                {
                    airwaybill = context.Request.Form["airwaybill"];
                }
                if (context.Request.QueryString["shippingtype"] != null)
                {
                    shippingtype = context.Request.QueryString["shippingtype"];
                }
                else if (context.Request.Form["shippingtype"] != null)
                {
                    shippingtype = context.Request.Form["shippingtype"];
                }

                if (context.Request.QueryString["shippingdate"] != null)
                {
                    if (Convert.ToString(context.Request.QueryString["shippingdate"]) == "N/A")
                    {
                    }
                    else
                    {
                        shippingdate = Convert.ToDateTime(context.Request.QueryString["shippingdate"]);
                    }
                }
                else if (context.Request.Form["shippingdate"] != null)
                {
                    if (context.Request.Form["shippingdate"] == "N/A")
                    {
                    }
                    else
                    {
                        shippingdate = Convert.ToDateTime(context.Request.Form["shippingdate"]);
                    }
                }

                if (context.Request.QueryString["expecteddeliverydate"] != null)
                {
                    if (Convert.ToString(context.Request.QueryString["expecteddeliverydate"]) == "N/A")
                    {
                    }
                    else
                    {
                        expecteddeliverydate = Convert.ToDateTime(context.Request.QueryString["expecteddeliverydate"]);
                    }
                }
                else if (context.Request.Form["expecteddeliverydate"] != null)
                {
                    if (context.Request.Form["expecteddeliverydate"] == "N/A")
                    {
                    }
                    else
                    {
                        expecteddeliverydate = Convert.ToDateTime(context.Request.Form["expecteddeliverydate"]);
                    }
                }
                if (context.Request.QueryString["dockno"] != null)
                {
                    dockno = context.Request.QueryString["dockno"];
                }
                else if (context.Request.Form["dockno"] != null)
                {
                    dockno = context.Request.Form["dockno"];
                }
                if (context.Request.QueryString["lrno"] != null)
                {
                    lrno = context.Request.QueryString["lrno"];
                }
                else if (context.Request.Form["lrno"] != null)
                {
                    lrno = context.Request.Form["lrno"];
                }
                if (context.Request.QueryString["intime"] != null)
                {
                    intime = context.Request.QueryString["intime"];
                }
                else if (context.Request.Form["intime"] != null)
                {
                    intime = context.Request.Form["intime"];
                }
                if (context.Request.QueryString["outtime"] != null)
                {
                    outtime = context.Request.QueryString["outtime"];
                }
                else if (context.Request.Form["outtime"] != null)
                {
                    outtime = context.Request.Form["outtime"];
                }
                if (context.Request.QueryString["productdetail"] != null)
                {
                    productdetail = context.Request.QueryString["productdetail"];
                }
                else if (context.Request.Form["productdetail"] != null)
                {
                    productdetail = context.Request.Form["productdetail"];
                }

                if (context.Request.QueryString["other"] != null)
                {
                    udr = context.Request.QueryString["other"];
                }
                else if (context.Request.Form["other"] != null)
                {
                    udr = context.Request.Form["other"];
                }

                //context.Response.ContentType = "text/plain";
                //jsonString = String.Empty;
                long           CustomerID, CompanyID;
                string         DuplicateLottable = "";
                string         userName          = GetUserID(uid);
                CustomProfile  profile           = CustomProfile.GetProfile(userName);
                iInboundClient Inbound           = new iInboundClient();
                tGRNHead       GRNHead           = new tGRNHead();
                GRNHead.CreatedBy    = uid;
                GRNHead.Creationdate = DateTime.Now;
                GRNHead.ObjectName   = objectname;
                GRNHead.OID          = oid;
                GRNHead.ShipID       = "";
                GRNHead.GRNDate      = DateTime.Now;
                GRNHead.ReceivedBy   = uid;
                GRNHead.BatchNo      = batchcode;
                if (remark == "N/A")
                {
                    remark = "";
                }
                GRNHead.Remark = remark;
                if (airwaybill == "N/A")
                {
                    airwaybill = "";
                }
                GRNHead.AirwayBill = airwaybill;
                if (shippingtype == "N/A")
                {
                    shippingtype = "";
                }
                GRNHead.ShippingType = shippingtype;
                GRNHead.CompanyID    = profile.Personal.CompanyID;
                GRNHead.CustomerID   = profile.Personal.CustomerId;
                GRNHead.Status       = getStatus(objectname);
                Status = getStatus(objectname);
                GRNHead.ShippingDate      = shippingdate;
                GRNHead.TransporterRemark = "";
                //GRNHead.TransporterID = ;
                // GRNHead.DockNo = dockno;
                //GRNHead.TruckNo = "";
                if (lrno == "N/A")
                {
                    lrno = "";
                }
                GRNHead.LRNo = lrno;
                if (intime == "N/A")
                {
                    intime = "";
                }
                GRNHead.InTime = intime;
                if (outtime == "N/A")
                {
                    outtime = "";
                }
                GRNHead.OutTime         = outtime;
                GRNHead.ExpDeliveryDate = expecteddeliverydate;
                GRNHead.IsRead          = false;
                GRNHead.Other           = udr;

                //DataTable dtnew = new DataTable();
                //dtnew = GetDatatableDetails("select * from tgrnhead where oid=" + oid + "");
                //if (dtnew.Rows.Count > 0)
                //{
                //    GRNID = Convert.ToInt64(dtnew.Rows[0]["ID"].ToString());
                //}
                //else
                //{
                //    GRNID = Inbound.SavetGRNHead(GRNHead, profile.DBConnection._constr);
                //}
                GRNID = GetGRNStatus(oid, objectname);
                if (GRNID == 0)
                {
                    GRNID = Inbound.SavetGRNHead(GRNHead, profile.DBConnection._constr);
                }

                /* GRNDetail */
                string         mygrnPrdString1 = "select * from SplitString('" + productdetail + "','@')";
                SqlCommand     cmd1            = new SqlCommand();
                SqlDataAdapter da1             = new SqlDataAdapter();
                DataSet        ds1             = new DataSet();
                DataTable      dt1             = new DataTable();
                SqlDataReader  dr1;
                cmd1.CommandType = CommandType.Text;
                cmd1.CommandText = mygrnPrdString1;
                cmd1.Connection  = conn;
                cmd1.Parameters.Clear();
                da1.SelectCommand = cmd1;
                da1.Fill(ds1, "tbl2");
                dt1 = ds1.Tables[0];
                int cntr1 = dt1.Rows.Count;
                if (cntr1 > 0)
                {
                    for (int P = 0; P <= cntr1 - 1; P++)
                    {
                        string productdetail1 = ds1.Tables[0].Rows[P]["part"].ToString().Trim();
                        string prdString, qtystring; long prdID;

                        decimal qty = 0;
                        string  lot1str, lot2str, lot3str, lot1 = "", lot2 = "", lot3 = "";
                        dt.Clear();
                        string mygrnPrdString = "select * from SplitString('" + productdetail1 + "','|')";
                        cmd.CommandType = CommandType.Text;
                        cmd.CommandText = mygrnPrdString;
                        cmd.Connection  = conn;
                        cmd.Parameters.Clear();
                        da.SelectCommand = cmd;
                        da.Fill(ds, "tbl1");
                        dt = ds.Tables[0];
                        int cntr = dt.Rows.Count;
                        if (cntr > 0)
                        {
                            for (int i = 0; i <= cntr - 1; i++)
                            {
                                prdString = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                                string[] spltprdString = prdString.Split(':');
                                prdID     = long.Parse(spltprdString[1]);
                                i         = i + 1;
                                qtystring = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                                string[] spltqty = qtystring.Split(':');
                                qty = decimal.Parse(spltqty[1]);
                                if (cntr > 2)
                                {
                                    i       = i + 1;
                                    lot1str = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                                    string[] lotsplit = lot1str.Split(':');
                                    lot1 = lotsplit[1];
                                    //DuplicateLottable = ChkDuplicateLottable(lot1, profile.Personal.CompanyID, profile.Personal.CustomerId);
                                    DuplicateLottable = "NO";
                                    //if (objectname == "SalesReturn")
                                    //{
                                    //    DuplicateLottable = "No";
                                    //}
                                    //if (DuplicateLottable == "Yes")
                                    //{
                                    //    break;
                                    //}
                                    //else { }
                                }
                                if (cntr > 3)
                                {
                                    i       = i + 1;
                                    lot2str = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                                    string[] lot2split = lot2str.Split(':');
                                    lot2 = lot2split[1];
                                }
                                if (cntr > 4)
                                {
                                    i       = i + 1;
                                    lot3str = ds.Tables[0].Rows[i]["part"].ToString().Trim();
                                    string[] lot3split = lot3str.Split(':');
                                    lot3 = lot3split[1];
                                }
                                //i = i + 1;
                                DataSet dsOrder = new DataSet();
                                dsOrder = GetUOMofPrd(oid, objectname, prdID);

                                decimal poqty = 0;
                                long    UOMID = long.Parse(dsOrder.Tables[0].Rows[0]["UOMID"].ToString());

                                if (objectname == "PurchaseOrder")
                                {
                                    poqty = decimal.Parse(dsOrder.Tables[0].Rows[0]["OrderQty"].ToString());
                                }
                                else if (objectname == "Transfer")
                                {
                                    poqty = decimal.Parse(dsOrder.Tables[0].Rows[0]["Qty"].ToString());
                                }
                                else if (objectname == "SalesReturn")
                                {
                                    poqty = decimal.Parse(dsOrder.Tables[0].Rows[0]["OrderQty"].ToString());
                                }
                                decimal totalgrnqty = 0;

                                DataTable dtgrn = new DataTable();
                                dtgrn = GetDatatableDetails("select isnull(sum(grnqty),0) as grnqty from tgrndetail where grnid=" + GRNID + " and prodid=" + prdID + "");
                                if (dtgrn.Rows.Count > 0)
                                {
                                    totalgrnqty = Convert.ToDecimal(dtgrn.Rows[0]["grnqty"].ToString());
                                }
                                decimal ShortQty = 0, ExcessQty = 0; decimal qtyCalculation = 0;
                                // decimal qtyCalculation = poqty - qty;
                                if (totalgrnqty == 0)
                                {
                                    qtyCalculation = poqty - qty;
                                }
                                else
                                {
                                    qtyCalculation = poqty - totalgrnqty;
                                }
                                if (qtyCalculation == 0)
                                {
                                    ShortQty = 0; ExcessQty = 0;
                                }
                                else if (qtyCalculation > 0)
                                {
                                    ShortQty = qtyCalculation; ExcessQty = 0;
                                }
                                else if (qtyCalculation < 0)
                                {
                                    ShortQty = 0; ExcessQty = Math.Abs(qtyCalculation);
                                }

                                SqlCommand     cmdDetail = new SqlCommand();
                                SqlDataAdapter daDetail  = new SqlDataAdapter();
                                DataSet        dsDetail  = new DataSet();
                                DataTable      dtDetail  = new DataTable();
                                // SqlConnection conn = new SqlConnection(strcon);
                                cmdDetail.CommandType = CommandType.StoredProcedure;
                                cmdDetail.CommandText = "SP_MobileInsertGRNDetails";
                                cmdDetail.Connection  = conn;
                                cmdDetail.Parameters.Clear();
                                cmdDetail.Parameters.AddWithValue("GRNID", GRNID);
                                cmdDetail.Parameters.AddWithValue("prdID", prdID);
                                cmdDetail.Parameters.AddWithValue("qty", qty);
                                cmdDetail.Parameters.AddWithValue("poqty", poqty);
                                cmdDetail.Parameters.AddWithValue("ShortQty", ShortQty);
                                cmdDetail.Parameters.AddWithValue("ExcessQty", ExcessQty);
                                cmdDetail.Parameters.AddWithValue("UOMID", UOMID);
                                cmdDetail.Parameters.AddWithValue("lot1", lot1);
                                cmdDetail.Parameters.AddWithValue("lot2", lot2);
                                cmdDetail.Parameters.AddWithValue("lot3", lot3);
                                cmdDetail.Parameters.AddWithValue("obj", objectname);
                                cmdDetail.Parameters.AddWithValue("CompanyId", profile.Personal.CompanyID);
                                cmdDetail.Parameters.AddWithValue("CustomerId", profile.Personal.CustomerId);
                                cmdDetail.Connection.Open();
                                cmdDetail.ExecuteNonQuery();
                                cmdDetail.Connection.Close();
                            }
                        }
                        if (DuplicateLottable == "Yes")
                        {
                            break;
                        }

                        // jsonString = "{\n\"arr_qc_list\":[\n";
                    }
                    updateGRNStatus(GRNID);
                    if (DuplicateLottable == "Yes")
                    {
                        RecordUpdateStatus(GRNID, objectname, Status, oid);
                        jsonString = jsonString + "{\n";
                        jsonString = jsonString + "\"status\": \"failed\",\n";
                        jsonString = jsonString + "\"reason\": \"duplicateserial\"\n";
                        jsonString = jsonString + "}\n";
                        jsonString = jsonString + "]\n}";
                        context.Response.Write(jsonString);
                    }
                    else
                    {
                        RecordUpdateStatus(GRNID, objectname, Status, oid);
                        jsonString = jsonString + "{\n";
                        jsonString = jsonString + "\"status\": \"success\",\n";
                        jsonString = jsonString + "\"reason\": \"\"\n";
                        jsonString = jsonString + "}\n";
                        jsonString = jsonString + "]\n}";
                        context.Response.Write(jsonString);
                    }
                }
            }
            catch (System.Exception ex)
            {
                ErrorLog(ex.ToString(), "Save_GRN");
                Login.Profile.ErrorHandling(ex, "ws-save-grn", "ProcessRequest");
                // throw ex;
                jsonString = jsonString + "{\n";
                jsonString = jsonString + "\"status\": \"failed\",\n";
                jsonString = jsonString + "\"reason\": \"servererror\"\n";
                jsonString = jsonString + "}\n";
                jsonString = jsonString + "]\n}";
                context.Response.Write(jsonString);
            }
            finally
            { }
        }
        public void ProcessRequest(HttpContext context)
        {
            SqlConnection conn  = new SqlConnection(strcon);
            long          GRNID = 0;

            try
            {
                if (context.Request.QueryString["objname"] != null)
                {
                    objname = context.Request.QueryString["objname"].ToString();
                }
                if (context.Request.QueryString["oid"] != null)
                {
                    orderID = long.Parse(context.Request.QueryString["oid"]);
                }
                if (context.Request.QueryString["wrid"] != null)
                {
                    WarehouseID = long.Parse(context.Request.QueryString["wrid"]);
                }
                if (context.Request.QueryString["serialno"] != null)
                {
                    serialno = (context.Request.QueryString["serialno"]).ToString();
                }
                if (context.Request.QueryString["uid"] != null)
                {
                    UserID = Convert.ToInt64(context.Request.QueryString["uid"]);
                }
                if (context.Request.QueryString["page"] != null)
                {
                    page = (context.Request.QueryString["page"]).ToString();
                }

                DataSet dsUserDetail = new DataSet();
                dsUserDetail = GetUserDetails(UserID);
                CompanyID    = long.Parse(dsUserDetail.Tables[0].Rows[0]["CompanyID"].ToString());
                CustomerID   = long.Parse(dsUserDetail.Tables[0].Rows[0]["CustomerID"].ToString());

                long PrdID = 0;
                PrdID = GetPrdID(serialno, CompanyID, CustomerID);
                if (PrdID == 0)
                {
                    PrdID = GetPrdIDNew(serialno, CompanyID, CustomerID);
                }
                if (PrdID == 0)
                {
                    PrdID = GetPrdIDNewCode(serialno, CompanyID, CustomerID);
                }

                context.Response.ContentType = "text/plain";
                String jsonString = String.Empty;
                jsonString = "{\n";   /*json Loop Start*/
                jsonString = jsonString + "\"result\":[{\n";
                if (PrdID == 0)
                {
                    jsonString = jsonString + "\"status\": \"failed\",\n";
                    jsonString = jsonString + "\"reason\": \"SKU Not Available\"\n";
                }
                else
                {
                    DataTable dtorder = new DataTable();
                    dtorder = CheckSKUInOrder(PrdID, orderID, objname);
                    if (dtorder.Rows.Count > 0)
                    {
                        DataTable dtsrno = new DataTable();
                        dtsrno = CheckDuplicateSrNo(serialno, CompanyID, CustomerID, page, objname);
                        if (dtsrno.Rows.Count > 0)
                        {
                            jsonString = jsonString + "\"status\": \"failed\",\n";
                            jsonString = jsonString + "\"reason\": \"Serial number already used\"\n";
                        }
                        else
                        {
                            DataTable dtcurcnt = new DataTable();
                            dtcurcnt = GetCurrentCount(orderID, objname, PrdID);
                            decimal grnqty = 0;
                            decimal oqty   = 1;
                            if (dtcurcnt.Rows.Count > 0)
                            {
                                grnqty = Convert.ToDecimal(dtcurcnt.Rows[0]["GRNQty"]);
                                oqty   = Convert.ToDecimal(dtcurcnt.Rows[0]["OQty"]);
                            }
                            if (grnqty >= oqty)
                            {
                                jsonString = jsonString + "\"status\": \"failed\",\n";
                                jsonString = jsonString + "\"reason\": \"You have already reached max count\"\n";
                            }
                            else
                            {
                                iInboundClient Inbound  = new iInboundClient();
                                string         userName = GetUserID(UserID);
                                CustomProfile  profile  = CustomProfile.GetProfile(userName);
                                tGRNHead       GRNHead  = new tGRNHead();
                                GRNHead.ObjectName   = objname;
                                GRNHead.OID          = orderID;
                                GRNHead.GRNDate      = DateTime.Now;
                                GRNHead.ReceivedBy   = UserID;
                                GRNHead.BatchNo      = GEtBatchcode(orderID);
                                GRNHead.CreatedBy    = UserID;
                                GRNHead.Creationdate = DateTime.Now;
                                GRNHead.CustomerID   = CustomerID;
                                GRNHead.CompanyID    = CompanyID;
                                GRNHead.Status       = getStatus(objname);
                                GRNHead.OrderFrom    = "Mobile";
                                GRNID = GetGRNStatus(orderID, objname, UserID);
                                if (GRNID == 0)
                                {
                                    GRNID = Inbound.SavetGRNHead(GRNHead, profile.DBConnection._constr);
                                }
                                if (GRNID > 0)
                                {
                                    int save = SaveGRNDetail(orderID, objname, GRNID, PrdID, 1);
                                    SaveLottable(serialno, objname, GRNID, PrdID, 1, CompanyID, CustomerID, WarehouseID);
                                    string WorkFlow = "", NextObject = "";
                                    int    count = 0;
                                    long   QCID  = 0;
                                    if (objname == "PurchaseOrder")
                                    {
                                        WorkFlow   = "Inbound";
                                        NextObject = "QC";
                                    }
                                    if (objname == "Transfer")
                                    {
                                        WorkFlow   = "Transfer";
                                        NextObject = "QC";
                                    }
                                    if (objname == "SalesReturn")
                                    {
                                        WorkFlow   = "Return";
                                        NextObject = "QC";
                                    }
                                    count = GetWorkFlow(profile.Personal.CompanyID, profile.Personal.CustomerId, WorkFlow, NextObject, profile.DBConnection._constr);
                                    if (count == 0)
                                    {
                                        tQualityControlHead QCHead = new tQualityControlHead();
                                        QCHead.CreatedBy    = profile.Personal.UserID;
                                        QCHead.Creationdate = DateTime.Now;
                                        QCHead.ObjectName   = objname;
                                        QCHead.OID          = GRNID;
                                        QCHead.QCDate       = DateTime.Now;
                                        QCHead.QCBy         = profile.Personal.UserID;
                                        QCHead.Remark       = "";
                                        if (objname == "PurchaseOrder")
                                        {
                                            WorkFlow   = "Inbound";
                                            NextObject = "LabelPrinting";
                                        }
                                        if (objname == "Transfer")
                                        {
                                            WorkFlow   = "Transfer";
                                            NextObject = "LabelPrinting";
                                        }
                                        if (objname == "SalesReturn")
                                        {
                                            WorkFlow   = "Return";
                                            NextObject = "LabelPrinting";
                                        }
                                        int count1 = GetWorkFlow(profile.Personal.CompanyID, profile.Personal.CustomerId, WorkFlow, NextObject, profile.DBConnection._constr);

                                        if (objname == "PurchaseOrder")
                                        {
                                            if (count1 == 0)
                                            {
                                                QCHead.Status = 33;
                                            }
                                            else
                                            {
                                                QCHead.Status = 32;
                                            }
                                        }
                                        else if (objname == "Transfer")
                                        {
                                            if (count1 == 0)
                                            {
                                                QCHead.Status = 71;
                                            }
                                            else
                                            {
                                                QCHead.Status = 60;
                                            }
                                        }
                                        else if (objname == "SalesReturn")
                                        {
                                            if (count1 == 0)
                                            {
                                                QCHead.Status = 53;
                                            }
                                            else
                                            {
                                                QCHead.Status = 52;
                                            }
                                        }

                                        QCHead.Company    = profile.Personal.CompanyID;
                                        QCHead.CustomerID = profile.Personal.CustomerId;
                                        QCHead.OrderFrom  = "Mobile";
                                        QCID = GetQCStatus(GRNID, objname, UserID);
                                        if (QCID == 0)
                                        {
                                            QCID = Inbound.SavetQualityControlHead(QCHead, profile.DBConnection._constr);
                                        }
                                        if (QCID > 0)
                                        {
                                            SaveQCDetails(GRNID, QCID, PrdID, 1);
                                            SaveLottableQC(serialno, objname, QCID, PrdID, 1, CompanyID, CustomerID, WarehouseID);
                                        }
                                    }
                                    if (save > 0)
                                    {
                                        jsonString = jsonString + "\"status\": \"success\",\n";
                                        jsonString = jsonString + "\"reason\": \"\"\n";
                                    }
                                    else
                                    {
                                        jsonString = jsonString + "\"status\": \"failed\",\n";
                                        jsonString = jsonString + "\"reason\": \"Server error occured\"\n";
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        jsonString = jsonString + "\"status\": \"failed\",\n";
                        jsonString = jsonString + "\"reason\": \"SKU Not Available In Order\"\n";
                    }
                }

                jsonString = jsonString + "}]\n";
                jsonString = jsonString + "}\n"; /*json Loop End*/
                context.Response.Write(jsonString);
            }
            catch (Exception ex)
            { Login.Profile.ErrorHandling(ex, "scan_serial_and_save", "ProcessRequest"); }
            finally
            { }
        }
        public void ProcessRequest(HttpContext context)
        {
            SqlConnection conn = new SqlConnection(strcon);
            long          PKID = 0;

            try
            {
                if (context.Request.QueryString["objname"] != null)
                {
                    objname = context.Request.QueryString["objname"].ToString();
                }
                if (context.Request.QueryString["oid"] != null)
                {
                    orderID = long.Parse(context.Request.QueryString["oid"]);
                }
                if (context.Request.QueryString["wrid"] != null)
                {
                    WarehouseID = long.Parse(context.Request.QueryString["wrid"]);
                }
                if (context.Request.QueryString["serialno"] != null)
                {
                    serialno = (context.Request.QueryString["serialno"]).ToString();
                }
                if (context.Request.QueryString["uid"] != null)
                {
                    UserID = Convert.ToInt64(context.Request.QueryString["uid"]);
                }
                if (context.Request.QueryString["page"] != null)
                {
                    page = (context.Request.QueryString["page"]).ToString();
                }
                if (context.Request.QueryString["loc"] != null)
                {
                    LocID = Convert.ToInt64(context.Request.QueryString["loc"]);
                }
                DataSet dsUserDetail = new DataSet();
                dsUserDetail = GetUserDetails(UserID);
                CompanyID    = long.Parse(dsUserDetail.Tables[0].Rows[0]["CompanyID"].ToString());
                CustomerID   = long.Parse(dsUserDetail.Tables[0].Rows[0]["CustomerID"].ToString());

                long PrdID = 0;
                PrdID = GetPrdID(serialno, CompanyID, CustomerID);
                if (PrdID == 0)
                {
                    PrdID = GetPrdIDNew(serialno, CompanyID, CustomerID);
                }
                if (PrdID == 0)
                {
                    PrdID = GetPrdIDNewCode(serialno, CompanyID, CustomerID);
                }
                if (PrdID == 0)
                {
                    string[] prodid = serialno.Split('_');
                    string   batch  = "Batch-" + prodid[1].ToString();
                    PrdID = GetPrdIDNewCodeMarvel(Convert.ToInt64(prodid[0]), CompanyID, CustomerID);
                    if (PrdID > 0)
                    {
                        batchflag = "yes";
                        if (objname == "SalesOrder")
                        {
                            IsBatch = CheckSKUInBatch(orderID.ToString(), "", PrdID, batch);
                        }
                        else
                        {
                            IsBatch = CheckSKUInBatch("", orderID.ToString(), PrdID, batch);
                        }
                    }
                }
                context.Response.ContentType = "text/plain";
                String jsonString = String.Empty;
                jsonString = "{\n";   /*json Loop Start*/
                jsonString = jsonString + "\"result\":[{\n";
                if (PrdID == 0)
                {
                    jsonString = jsonString + "\"status\": \"failed\",\n";
                    jsonString = jsonString + "\"reason\": \"SKU Not Available\"\n";
                }
                else if (IsBatch == 0 && batchflag == "yes")
                {
                    jsonString = jsonString + "\"status\": \"failed\",\n";
                    jsonString = jsonString + "\"reason\": \"SKU Not Available in Batch\"\n";
                }
                else
                {
                    DataTable dtorder = new DataTable();
                    dtorder = CheckSKUInOrder(PrdID, orderID, objname);
                    if (dtorder.Rows.Count > 0)
                    {
                        DataTable dtstock = new DataTable();
                        dtstock = SrNoInStock(serialno, CustomerID, LocID, PrdID);
                        if (dtstock.Rows.Count > 0)
                        {
                            DataTable dtsrno = new DataTable();
                            dtsrno = CheckDuplicateSrNo(serialno, CompanyID, CustomerID, page, objname);
                            if (dtsrno.Rows.Count > 0)
                            {
                                jsonString = jsonString + "\"status\": \"failed\",\n";
                                jsonString = jsonString + "\"reason\": \"Serial number already used\"\n";
                            }
                            else
                            {
                                decimal pkqty = GetPkQty(orderID, objname, PrdID);
                                decimal oqty  = GetOrderQty(orderID, objname, PrdID);
                                if (pkqty >= oqty)
                                {
                                    jsonString = jsonString + "\"status\": \"failed\",\n";
                                    jsonString = jsonString + "\"reason\": \"You have already reached max count\"\n";
                                }
                                else
                                {
                                    iOutboundClient outbound = new iOutboundClient();
                                    string          userName = GetUserID(UserID);
                                    CustomProfile   profile  = CustomProfile.GetProfile(userName);
                                    tPickUpHead     pk       = new tPickUpHead();
                                    pk.ObjectName   = objname;
                                    pk.OID          = orderID;
                                    pk.PickUpDate   = DateTime.Now;
                                    pk.PickUpBy     = UserID;
                                    pk.Remark       = "";
                                    pk.CreatedBy    = UserID;
                                    pk.CreationDate = DateTime.Now;
                                    pk.Status       = getStatus(objname);
                                    pk.CompanyID    = CompanyID;
                                    pk.CustomerID   = CustomerID;
                                    pk.PickUpStatus = true;
                                    PKID            = GetPickUpStatus(orderID, objname, UserID);
                                    if (PKID == 0)
                                    {
                                        PKID = outbound.SavetPickUpHead(pk, profile.DBConnection._constr);
                                    }
                                    if (PKID > 0)
                                    {
                                        int save = SavePickUpDetail(orderID, objname, PKID, PrdID, 1, LocID, serialno);
                                        SaveLottablePickUp(serialno, objname, PKID, PrdID, 1, CompanyID, CustomerID, LocID);
                                        iInboundClient Inbound = new iInboundClient();
                                        string         WorkFlow = "", NextObject = "";
                                        int            count = 0;
                                        long           QCID  = 0;
                                        if (objname == "SalesOrder")
                                        {
                                            WorkFlow   = "Outbound";
                                            NextObject = "QC";
                                        }
                                        if (objname == "Transfer")
                                        {
                                            WorkFlow   = "Transfer";
                                            NextObject = "QCOut";
                                        }
                                        count = GetWorkFlow(profile.Personal.CompanyID, profile.Personal.CustomerId, WorkFlow, NextObject, profile.DBConnection._constr);
                                        if (count == 0)
                                        {
                                            WMSOutbound.tQualityControlHead QCHead = new WMSOutbound.tQualityControlHead();
                                            QCHead.CreatedBy    = profile.Personal.UserID;
                                            QCHead.Creationdate = DateTime.Now;
                                            QCHead.ObjectName   = objname;
                                            QCHead.OID          = PKID;
                                            QCHead.QCDate       = DateTime.Now;
                                            QCHead.QCBy         = profile.Personal.UserID;
                                            QCHead.Remark       = "";

                                            if (objname == "SalesOrder")
                                            {
                                                QCHead.Status = 32;
                                            }
                                            else if (objname == "Transfer")
                                            {
                                                QCHead.Status = 58;
                                            }

                                            QCHead.Company    = profile.Personal.CompanyID;
                                            QCHead.CustomerID = profile.Personal.CustomerId;
                                            QCID = GetQCStatus(PKID, objname, UserID);
                                            if (QCID == 0)
                                            {
                                                QCID = Inbound.SavetQualityControlHead(QCHead, profile.DBConnection._constr);
                                            }
                                            if (QCID > 0)
                                            {
                                                SaveQCDetails(PKID, QCID, PrdID, 1);
                                            }
                                        }
                                        if (save > 0)
                                        {
                                            jsonString = jsonString + "\"status\": \"success\",\n";
                                            jsonString = jsonString + "\"reason\": \"\"\n";
                                        }
                                        else
                                        {
                                            jsonString = jsonString + "\"status\": \"failed\",\n";
                                            jsonString = jsonString + "\"reason\": \"Server error occured\"\n";
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            jsonString = jsonString + "\"status\": \"failed\",\n";
                            jsonString = jsonString + "\"reason\": \"Serial No. not available in Stock OR Location\"\n";
                        }
                    }
                    else
                    {
                        jsonString = jsonString + "\"status\": \"failed\",\n";
                        jsonString = jsonString + "\"reason\": \"SKU Not Available In Order\"\n";
                    }
                }

                jsonString = jsonString + "}]\n";
                jsonString = jsonString + "}\n"; /*json Loop End*/
                context.Response.Write(jsonString);
            }
            catch (Exception ex)
            { Login.Profile.ErrorHandling(ex, "pickup_scan_serial_and_save", "ProcessRequest"); }
            finally
            { }
        }
        public void ProcessRequest(HttpContext context)
        {
            SqlConnection conn = new SqlConnection(strcon);
            long          PTID = 0;

            try
            {
                if (context.Request.Form["oid"] != null)
                {
                    orderID = long.Parse(context.Request.Form["oid"]);
                }
                if (context.Request.Form["wrid"] != null)
                {
                    WarehouseID = long.Parse(context.Request.Form["wrid"]);
                }
                if (context.Request.Form["objname"] != null)
                {
                    objname = context.Request.Form["objname"].ToString();
                }
                if (context.Request.Form["uid"] != null)
                {
                    UserID = long.Parse(context.Request.Form["uid"]);
                }
                if (context.Request.Form["page"] != null)
                {
                    page = context.Request.Form["page"].ToString();
                }
                if (context.Request.Form["isAllSelected"] != null)
                {
                    AllSelect = context.Request.Form["isAllSelected"].ToString();
                }
                if (context.Request.Form["Batch"] != null)
                {
                    Batch = context.Request.Form["Batch"].ToString();
                }
                if (context.Request.Form["loc"] != null)
                {
                    LocID = long.Parse(context.Request.Form["loc"]);
                }
                if (context.Request.Form["pid"] != null)
                {
                    ProdID = long.Parse(context.Request.Form["pid"]);
                }
                if (context.Request.Form["bulkdata"] != null)
                {
                    BulkData = context.Request.Form["bulkdata"].ToString();
                }

                iInboundClient Inbound      = new iInboundClient();
                string         userName     = GetUserID(UserID);
                CustomProfile  profile      = CustomProfile.GetProfile(userName);
                DataSet        dsUserDetail = new DataSet();
                dsUserDetail = GetUserDetails(UserID);
                CompanyID    = long.Parse(dsUserDetail.Tables[0].Rows[0]["CompanyID"].ToString());
                CustomerID   = long.Parse(dsUserDetail.Tables[0].Rows[0]["CustomerID"].ToString());
                int result = 0;
                context.Response.ContentType = "text/plain";
                String jsonString = String.Empty;
                jsonString = "{\n";   /*json Loop Start*/
                jsonString = jsonString + "\"result\":[{\n";
                if (AllSelect == "yes")
                {
                    result = BulkSavePutIn(orderID, objname, page, CompanyID, CustomerID, UserID, LocID, Batch, ProdID);
                    if (result > 0)
                    {
                        jsonString = jsonString + "\"status\": \"success\",\n";
                        jsonString = jsonString + "\"reason\": \"\"\n";
                    }
                    else
                    {
                        jsonString = jsonString + "\"status\": \"failed\",\n";
                        jsonString = jsonString + "\"reason\": \"Server error occured\"\n";
                    }
                }
                else
                {
                    tPutInHead ph = new tPutInHead();
                    ph.ObjectName   = objname;
                    ph.OID          = orderID;
                    ph.PutInDate    = DateTime.Now;
                    ph.PutInBy      = UserID;
                    ph.Remark       = "";
                    ph.CreatedBy    = UserID;
                    ph.CreationDate = DateTime.Now;
                    ph.Status       = getStatus(objname);
                    ph.Company      = CompanyID;
                    ph.CustomerID   = CustomerID;
                    ph.OrderFrom    = "Mobile";
                    PTID            = GetPTINStatus(orderID, objname, UserID);
                    if (PTID == 0)
                    {
                        PTID = Inbound.SavetPutInHead(ph, profile.DBConnection._constr);
                    }
                    if (PTID > 0)
                    {
                        int      save    = 0;
                        string[] srno    = BulkData.Split('|');
                        decimal  srcount = Convert.ToDecimal(srno.Length);
                        save = SavePutInDetail(orderID, PTID, ProdID, LocID, srcount, Batch);
                        for (int i = 0; i <= srcount - 1; i++)
                        {
                            SaveLottablePutIn(orderID, srno[i].ToString(), objname, PTID, ProdID, 1, CompanyID, CustomerID, UserID, LocID, Batch);
                        }

                        if (save > 0)
                        {
                            jsonString = jsonString + "\"status\": \"success\",\n";
                            jsonString = jsonString + "\"reason\": \"\"\n";
                        }
                        else
                        {
                            jsonString = jsonString + "\"status\": \"failed\",\n";
                            jsonString = jsonString + "\"reason\": \"Server error occured\"\n";
                        }
                    }
                }

                jsonString = jsonString + "}]\n";
                jsonString = jsonString + "}\n"; /*json Loop End*/
                context.Response.Write(jsonString);
            }
            catch (Exception ex)
            { Login.Profile.ErrorHandling(ex, "bulk_assign_location", "ProcessRequest"); }
            finally
            { }
        }
Beispiel #26
0
        public void ProcessRequest(HttpContext context)
        {
            SqlConnection conn = new SqlConnection(strcon);
            long          PTID = 0;

            try
            {
                if (context.Request.QueryString["objname"] != null)
                {
                    objname = context.Request.QueryString["objname"].ToString();
                }
                if (context.Request.QueryString["oid"] != null)
                {
                    orderID = long.Parse(context.Request.QueryString["oid"]);
                }
                if (context.Request.QueryString["wrid"] != null)
                {
                    WarehouseID = long.Parse(context.Request.QueryString["wrid"]);
                }
                if (context.Request.QueryString["serialno"] != null)
                {
                    serialno = (context.Request.QueryString["serialno"]).ToString();
                }
                if (context.Request.QueryString["uid"] != null)
                {
                    UserID = Convert.ToInt64(context.Request.QueryString["uid"]);
                }
                if (context.Request.QueryString["page"] != null)
                {
                    page = (context.Request.QueryString["page"]).ToString();
                }
                if (context.Request.QueryString["loc"] != null)
                {
                    LocID = Convert.ToInt64(context.Request.QueryString["loc"]);
                }
                if (context.Request.QueryString["batch"] != null)
                {
                    Batch = (context.Request.QueryString["batch"]).ToString();
                }

                DataSet dsUserDetail = new DataSet();
                dsUserDetail = GetUserDetails(UserID);
                CompanyID    = long.Parse(dsUserDetail.Tables[0].Rows[0]["CompanyID"].ToString());
                CustomerID   = long.Parse(dsUserDetail.Tables[0].Rows[0]["CustomerID"].ToString());

                long PrdID = 0;
                PrdID = GetPrdID(serialno, CompanyID, CustomerID);
                if (PrdID == 0)
                {
                    PrdID = GetPrdIDNew(serialno, CompanyID, CustomerID);
                }
                if (PrdID == 0)
                {
                    PrdID = GetPrdIDNewCode(serialno, CompanyID, CustomerID);
                }
                context.Response.ContentType = "text/plain";
                String jsonString = String.Empty;
                jsonString = "{\n";   /*json Loop Start*/
                jsonString = jsonString + "\"result\":[{\n";
                if (PrdID == 0)
                {
                    jsonString = jsonString + "\"status\": \"failed\",\n";
                    jsonString = jsonString + "\"reason\": \"SKU Not Available\"\n";
                }
                else
                {
                    DataTable dtorder = new DataTable();
                    dtorder = CheckSKUInOrder(PrdID, orderID, objname);
                    if (dtorder.Rows.Count > 0)
                    {
                        DataTable dtsrorder = new DataTable();
                        dtsrorder = CheckSrNoInOrder(orderID, serialno, objname, PrdID);
                        if (dtsrorder.Rows.Count > 0)
                        {
                            DataTable dtsrno = new DataTable();
                            dtsrno = CheckDuplicateSrNo(serialno, CompanyID, CustomerID, page, objname);
                            if (dtsrno.Rows.Count > 0)
                            {
                                jsonString = jsonString + "\"status\": \"failed\",\n";
                                jsonString = jsonString + "\"reason\": \"Serial number already used\"\n";
                            }
                            else
                            {
                                decimal ptqty = GetPtQty(orderID, objname, PrdID);
                                decimal oqty  = GetOrderQty(orderID, objname, PrdID);
                                if (ptqty >= oqty)
                                {
                                    jsonString = jsonString + "\"status\": \"failed\",\n";
                                    jsonString = jsonString + "\"reason\": \"You have already reached max count\"\n";
                                }
                                else
                                {
                                    tPutInHead     ph       = new tPutInHead();
                                    string         userName = GetUserID(UserID);
                                    CustomProfile  profile  = CustomProfile.GetProfile(userName);
                                    iInboundClient Inbound  = new iInboundClient();
                                    ph.ObjectName   = objname;
                                    ph.OID          = orderID;
                                    ph.PutInDate    = DateTime.Now;
                                    ph.PutInBy      = UserID;
                                    ph.Remark       = "";
                                    ph.CreatedBy    = UserID;
                                    ph.CreationDate = DateTime.Now;
                                    ph.Status       = getStatus(objname);
                                    ph.Company      = CompanyID;
                                    ph.CustomerID   = CustomerID;
                                    ph.OrderFrom    = "Mobile";
                                    PTID            = GetPTINStatus(orderID, objname, UserID);
                                    if (PTID == 0)
                                    {
                                        PTID = Inbound.SavetPutInHead(ph, profile.DBConnection._constr);
                                    }
                                    if (PTID > 0)
                                    {
                                        int save = SavePutInDetail(orderID, PTID, PrdID, LocID, 1, Batch);
                                        SaveLottablePutIn(orderID, serialno, objname, PTID, PrdID, 1, CompanyID, CustomerID, UserID, LocID, Batch);
                                        if (save > 0)
                                        {
                                            jsonString = jsonString + "\"status\": \"success\",\n";
                                            jsonString = jsonString + "\"reason\": \"\"\n";
                                        }
                                        else
                                        {
                                            jsonString = jsonString + "\"status\": \"failed\",\n";
                                            jsonString = jsonString + "\"reason\": \"Server error occured\"\n";
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            jsonString = jsonString + "\"status\": \"failed\",\n";
                            jsonString = jsonString + "\"reason\": \"Serial No. Not Available In Order\"\n";
                        }
                    }
                    else
                    {
                        jsonString = jsonString + "\"status\": \"failed\",\n";
                        jsonString = jsonString + "\"reason\": \"SKU Not Available In Order\"\n";
                    }
                }

                jsonString = jsonString + "}]\n";
                jsonString = jsonString + "}\n"; /*json Loop End*/
                context.Response.Write(jsonString);
            }
            catch (Exception ex)
            { Login.Profile.ErrorHandling(ex, "putin_scan_serial_and_save", "ProcessRequest"); }
            finally
            { }
        }