public AssigningResponse BinData(AssigningReq CMR)
        {
            AssigningResponse res = new AssigningResponse();

            try
            {
                if (CMR == null)
                {
                    res.Status  = "Failure";
                    res.Message = "Object reference not set to an instance of an object.";
                }
                else
                {
                    query     = "Sp_AssignWebApi";
                    dbcommand = new SqlCommand(query, conn);
                    dbcommand.Connection.Open();
                    dbcommand.CommandType = CommandType.StoredProcedure;
                    dbcommand.Parameters.AddWithValue("@QueryType", "GetBinData");
                    dbcommand.Parameters.AddWithValue("@WareHouseID", CMR.WareHouseID);
                    dbcommand.Parameters.AddWithValue("@aisle", CMR.Aisle);
                    dbcommand.Parameters.AddWithValue("@rack", CMR.Rack);

                    dbcommand.CommandTimeout = 0;
                    SqlDataAdapter da = new SqlDataAdapter(dbcommand);
                    DataSet        ds = new DataSet();
                    da.Fill(ds);

                    List <BinList> BinList = new List <BinList>();
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        BinList A = new BinList();
                        A.name = row["name"].ToString();
                        A.id   = row["id"].ToString();
                        BinList.Add(A);
                    }
                    res.BinList = BinList;
                    res.Status  = "Success";
                    res.Message = "Data retrived successfully";
                }
            }
            catch (Exception Ex)
            {
                res.Status  = "Failure";
                res.Message = Ex.Message;
            }
            finally
            {
                dbcommand.Connection.Close();
            }
            return(res);
        }
        public ReceivingResponse UpdateAssignation(AssigningReq AR)
        {
            ReceivingResponse res = new ReceivingResponse();

            try
            {
                if (AR == null)
                {
                    res.Status  = "Failure";
                    res.Message = "Object reference not set to an instance of an object.";
                }
                if (AR.StickerNo == "")
                {
                    res.Status  = "Failure";
                    res.Message = "Invalid Sticker No.";
                }
                else
                {
                    query                    = "Sp_AssignWebApi";
                    dbcommand                = new SqlCommand(query, conn);
                    dbcommand.CommandType    = CommandType.StoredProcedure;
                    dbcommand.CommandTimeout = 0;
                    dbcommand.Parameters.AddWithValue("@QueryType", "FetchDataAssigning");
                    dbcommand.Parameters.AddWithValue("@StillageID", AR.StickerNo);
                    dbcommand.Parameters.AddWithValue("@UserId", AR.UserId);
                    dbcommand.Parameters.AddWithValue("@Aisle", AR.Aisle);
                    dbcommand.Parameters.AddWithValue("@Bin", AR.Bin);
                    dbcommand.Parameters.AddWithValue("@Rack", AR.Rack);
                    dbcommand.Parameters.AddWithValue("@Zone", AR.Zone);
                    dbcommand.Parameters.AddWithValue("@AssignedUser", AR.AssignedFLT);
                    dbcommand.Parameters.AddWithValue("@WareHouseID", AR.WareHouseID);
                    SqlDataAdapter daGetData = new SqlDataAdapter(dbcommand);
                    DataSet        dsGetData = new DataSet();
                    daGetData.Fill(dsGetData);
                    SqlDataAdapter da = new SqlDataAdapter(dbcommand);

                    var Hold = "";
                    if (dsGetData.Tables[0].Rows[0]["isHold"].ToString() == "True")
                    {
                        Hold = "Qc Hold";
                    }
                    else
                    {
                        Hold = "Qc Release";
                    }



                    if (dsGetData.Tables[0].Rows[0]["value"].ToString() != "2")
                    {
                        query     = "Sp_AxWebserviceIntegration";
                        dbcommand = new SqlCommand(query, conn);
                        //  dbcommand.Connection.Open();
                        dbcommand.CommandType    = CommandType.StoredProcedure;
                        dbcommand.CommandTimeout = 0;
                        da = new SqlDataAdapter(dbcommand);
                        DataSet ds = new DataSet();
                        da.Fill(ds);

                        //  DataSet ds = CommonManger.FillDatasetWithParam("Sp_AxWebserviceIntegration");
                        NeproWebApi.AXWebServiceRef1.Iace_FinishedGoodServiceClient obj = new NeproWebApi.AXWebServiceRef1.Iace_FinishedGoodServiceClient();
                        obj.ClientCredentials.Windows.ClientCredential.Domain   = Convert.ToString(ds.Tables[0].Rows[0]["Domain"]);
                        obj.ClientCredentials.Windows.ClientCredential.UserName = Convert.ToString(ds.Tables[0].Rows[0]["Username"]);
                        obj.ClientCredentials.Windows.ClientCredential.Password = Convert.ToString(ds.Tables[0].Rows[0]["Password"]);

                        NeproWebApi.AXWebServiceRef1.CallContext Cct = new NeproWebApi.AXWebServiceRef1.CallContext();
                        Cct.Company  = Convert.ToString(ds.Tables[0].Rows[0]["Company"]);
                        Cct.Language = Convert.ToString(ds.Tables[0].Rows[0]["Language"]);
                        string value = obj.InsertHistoryHeaderData(Cct, AR.StickerNo, Convert.ToString(dsGetData.Tables[0].Rows[0]["SiteID"]), Convert.ToString(dsGetData.Tables[0].Rows[0]["WorkOrderNo"]), Convert.ToString(dsGetData.Tables[0].Rows[0]["ItemId"]), Convert.ToDecimal(dsGetData.Tables[0].Rows[0]["WorkOrderQty"]));
                        //obj.InsertHistoryDetailData(Cct, AR .StickerNo, "", Convert.ToString(dsGetData.Tables[1].Rows[0]["ActivityName"]), Convert.ToString(dsGetData.Tables[1].Rows[0]["ActivityDesc"]), Convert.ToString(dsGetData.Tables[2].Rows[0]["ZONEID"]), "", Convert.ToString(dsGetData.Tables[1].Rows[0]["AssignedFLT"]), Convert.ToString(dsGetData.Tables[1].Rows[0]["StillageLocation"]), "", "", "", "No", 0, "", 0, 0, Convert.ToDecimal(dsGetData.Tables[1].Rows[0]["StillageQty"]), Convert.ToString(dsGetData.Tables[1].Rows[0]["UserName"]), "", 0, "");

                        obj.InsertHistoryDetailData(Cct, AR.StickerNo, "", Convert.ToString(dsGetData.Tables[1].Rows[0]["ActivityName"]), Convert.ToString(dsGetData.Tables[1].Rows[0]["ActivityDesc"]), Convert.ToString(dsGetData.Tables[1].Rows[0]["StillageLocation"]), "", Convert.ToString(dsGetData.Tables[1].Rows[0]["AssignedFLT"]), "", Convert.ToString(dsGetData.Tables[2].Rows[0]["ZONEID"]), "", "", "No", 0, "", 0, 0, Convert.ToDecimal(dsGetData.Tables[1].Rows[0]["StillageQty"]), Convert.ToString(dsGetData.Tables[1].Rows[0]["UserName"]), Hold, 0, "", "", "", Convert.ToString(dsGetData.Tables[1].Rows[0]["WareHouseID"]), 0);
                    }
                    else
                    {
                        res.Status  = "Failure";
                        res.Message = "This Stillage Does Not Exist";
                        return(res);
                    }



                    query     = "[Sp_AssignWebApi]";
                    dbcommand = new SqlCommand(query, conn);
                    dbcommand.Connection.Open();
                    dbcommand.CommandType = CommandType.StoredProcedure;
                    dbcommand.Parameters.AddWithValue("@QueryType", "UpdateAssign");
                    dbcommand.Parameters.AddWithValue("@StickerId", AR.StickerNo);
                    dbcommand.Parameters.AddWithValue("@Aisle", AR.Aisle);
                    dbcommand.Parameters.AddWithValue("@Rack", AR.Rack);
                    dbcommand.Parameters.AddWithValue("@Bin", AR.Bin);
                    dbcommand.Parameters.AddWithValue("@UserId", AR.UserId);
                    dbcommand.Parameters.AddWithValue("@AssignedUser", AR.AssignedFLT);
                    dbcommand.Parameters.AddWithValue("@WareHouseID", AR.WareHouseID);
                    dbcommand.Parameters.AddWithValue("@Zone", AR.Zone);

                    dbcommand.CommandTimeout = 0;
                    da = new SqlDataAdapter(dbcommand);
                    DataTable dt = new DataTable();
                    da.Fill(dt);
                    if (dt.Rows[0]["value"].ToString() == "1")
                    {
                        res.Status  = "Success";
                        res.Message = "Stillage assigned successfully";
                    }
                    else
                    {
                        res.Status  = "Failure";
                        res.Message = "Stillage not successfully assigned.!";
                    }
                }
            }
            catch (Exception Ex)
            {
                res.Status  = "Failure";
                res.Message = Ex.Message;
            }
            finally
            {
                dbcommand.Connection.Close();
            }
            return(res);
        }
        public AssigningResponse AssignData(AssigningReq CMR)
        {
            AssigningResponse res = new AssigningResponse();

            try
            {
                if (CMR == null)
                {
                    res.Status  = "Failure";
                    res.Message = "Object reference not set to an instance of an object.";
                }
                else if (CMR.StickerNo == "")
                {
                    res.Status  = "Failure";
                    res.Message = "Invalid Sticker No.";
                }
                else
                {
                    query     = "Sp_AssignWebApi";
                    dbcommand = new SqlCommand(query, conn);
                    dbcommand.Connection.Open();
                    dbcommand.CommandType = CommandType.StoredProcedure;
                    dbcommand.Parameters.AddWithValue("@QueryType", "GetAssignedData");
                    dbcommand.Parameters.AddWithValue("@StickerId", CMR.StickerNo);
                    dbcommand.Parameters.AddWithValue("@UserId", CMR.UserId);
                    dbcommand.CommandTimeout = 0;
                    SqlDataAdapter da = new SqlDataAdapter(dbcommand);
                    DataSet        ds = new DataSet();
                    da.Fill(ds);
                    if (ds.Tables[0].Rows[0]["value"].ToString() != "3")
                    {
                        res.StillageLocation = Convert.ToString(ds.Tables[0].Rows[0]["StillageLocation"]);
                        if (ds != null && ds.Tables[0].Rows.Count > 0)
                        {
                            if (ds.Tables[0].Rows[0]["value"].ToString() == "1")
                            {
                                res.Status  = "Failure";
                                res.Message = "Don't have access to get the details";
                            }

                            //else if (res.StillageLocation != "NPRO-000001")
                            else
                            {
                                res.StickerID        = ds.Tables[0].Rows[0]["StickerID"].ToString();
                                res.StandardQty      = Convert.ToDecimal(ds.Tables[0].Rows[0]["StandardQty"]);
                                res.ItemId           = ds.Tables[0].Rows[0]["ItemId"].ToString();
                                res.Description      = ds.Tables[0].Rows[0]["Description"].ToString();
                                res.ItemStdQty       = Convert.ToDecimal(ds.Tables[0].Rows[0]["ItemStdQty"]);
                                res.WareHouseID      = Convert.ToString(ds.Tables[0].Rows[0]["WareHouseID"]);
                                res.IsAssignTransfer = Convert.ToByte(ds.Tables[0].Rows[0]["IsAssignTransfer"]);

                                List <AisleList> AisleList = new List <AisleList>();
                                foreach (DataRow row in ds.Tables[1].Rows)
                                {
                                    AisleList A = new AisleList();
                                    A.name = row["name"].ToString();
                                    A.id   = row["id"].ToString();
                                    AisleList.Add(A);
                                }
                                res.AisleList = AisleList;

                                //List<BinList> BinList = new List<BinList>();
                                //foreach (DataRow row in ds.Tables[3].Rows)
                                //{
                                //    BinList A = new BinList();
                                //    A.name = row["name"].ToString();
                                //    A.id = row["id"].ToString();
                                //    BinList.Add(A);
                                //}
                                //res.BinList = BinList;

                                //List<RackList> RackList = new List<RackList>();
                                //foreach (DataRow row in ds.Tables[2].Rows)
                                //{
                                //    RackList A = new RackList();
                                //    A.name = row["name"].ToString();
                                //    A.id = row["id"].ToString();
                                //    RackList.Add(A);
                                //}
                                //res.RackList = RackList;
                                List <ZoneList> ZoneList = new List <ZoneList>();
                                foreach (DataRow row in ds.Tables[2].Rows)
                                {
                                    ZoneList A = new ZoneList();
                                    A.name = row["name"].ToString();
                                    A.id   = row["id"].ToString();
                                    ZoneList.Add(A);
                                }
                                res.ZoneList = ZoneList;

                                List <FLTList> FLTList = new List <FLTList>();
                                foreach (DataRow row in ds.Tables[3].Rows)
                                {
                                    FLTList A = new FLTList();
                                    A.name = row["name"].ToString();
                                    A.id   = Convert.ToInt64(row["id"]);
                                    FLTList.Add(A);
                                }
                                res.FLTList = FLTList;



                                res.Status  = "Success";
                                res.Message = "Data retrived successfully";
                            }
                            //else
                            //{
                            //    res.Status = "Operation Invalid";
                            //    res.Message = "Stillage will only move to Loading Area.";

                            //}
                        }
                        else
                        {
                            res.Status  = "Failure";
                            res.Message = "Invalid Sticker Id";
                        }
                    }
                    else
                    {
                        res.Status  = "Failure";
                        res.Message = "This stillage does not exist";
                        return(res);
                    }
                }
            }
            catch (Exception Ex)
            {
                res.Status  = "Failure";
                res.Message = Ex.Message;
            }
            finally
            {
                dbcommand.Connection.Close();
            }
            return(res);
        }