Example #1
0
        private void updateFlag(DataSet ds)
        {
            //orderdetails flag set
            Dispatch     disp     = new Dispatch();
            DispatchData dispData = new DispatchData();

            for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
            {
                disp.OrderDetailsId = Convert.ToInt32(ds.Tables[0].Rows[i]["OrderDetailsID"]);

                int x = dispData.UpdateDispatch(disp);
                if (x > 0)
                {
                    continue;
                }
                else
                {
                    break;
                }
            }

            //DataSet ds1 = new DataSet();
            //if (dpCategory.SelectedItem.Value == "1")
            //{
            DataTable dt = new DataTable();
            //ds.ReadXml(Server.MapPath("~/Tabs/Dispatch/temp" + nm + ".xml"));

            var query = from a in ds.Tables[0].AsEnumerable()
                        select a.Field <string>("OrderID");

            var qur = query.AsEnumerable().Distinct();

            foreach (var item in qur)
            {
                DBDispatch.DispatchSceme(item);
            }
            //}
        }
Example #2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Dispatch     dispatch     = new Dispatch();
            DispatchData dispatchData = new DispatchData();



            DataSet ds = new DataSet();
            int     id = 0;

            ds.ReadXml(Server.MapPath("~/Tabs/Dispatch/temp.xml"));
            ds.Tables[0].Columns.Add("DispatchInfoId", typeof(int));
            id = Convert.ToInt32(ds.Tables[1].Rows[0]["id"]);
            id = id + 1;
            for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
            {
                ds.Tables[0].Rows[i]["DispatchInfoId"] = id;
            }
            Dispatch     disp     = new Dispatch();
            DispatchData dispData = new DispatchData();

            for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
            {
                disp.OrderDetailsId = Convert.ToInt32(ds.Tables[0].Rows[i]["OrderDetailsID"]);

                int x = dispData.UpdateDispatch(disp);
                if (x > 0)
                {
                    continue;
                }
                else
                {
                    break;
                }
            }

            string consString = ConfigurationManager.ConnectionStrings["projectConnection"].ConnectionString;

            using (SqlConnection con = new SqlConnection(consString))
            {
                using (SqlBulkCopy sqlBulkCopy = new SqlBulkCopy(con))
                {
                    //Set the database table name
                    sqlBulkCopy.DestinationTableName = "DispatchDetails";

                    //[OPTIONAL]: Map the DataTable columns with that of the database table
                    sqlBulkCopy.ColumnMappings.Add("DispatchInfoId", "DD_DispatchInfoId");
                    sqlBulkCopy.ColumnMappings.Add("OrderID", "DD_OrderId");
                    sqlBulkCopy.ColumnMappings.Add("OrderDetailsId", "DD_OrderDetailsId");
                    sqlBulkCopy.ColumnMappings.Add("Qty", "DD_NewQuantity");
                    // sqlBulkCopy.ColumnMappings.Add("Country", "DD_OrderDetailsId");
                    //sqlBulkCopy.ColumnMappings.Add("Country", "DD_OrderDetailsId");
                    con.Open();
                    sqlBulkCopy.WriteToServer(ds.Tables[0]);
                    con.Close();
                }
            }

            dispatch.RouteID          = Convert.ToInt32(ds.Tables[0].Rows[0]["RouteID"]);
            dispatch.DispatchId       = id;
            dispatch.SalesmanFirstId  = Convert.ToInt32(dpSalesman.SelectedValue);
            dispatch.SalesmanSecondId = Convert.ToInt32(dpSalesman2.SelectedValue);
            dispatch.DriverFirstId    = Convert.ToInt32(dpDriver.SelectedValue);
            dispatch.DriverSecondId   = Convert.ToInt32(dpDriver2.SelectedValue);
            dispatch.VehicleId        = Convert.ToInt32(dpVehicle.SelectedValue);
            dispatch.Cartons          = Convert.ToInt32(txtCartons.Text);
            dispatch.Trays            = Convert.ToInt32(txtTraysDispached.Text);
            dispatch.IceBox           = Convert.ToInt32(txtIceBox.Text);
            dispatch.OtherDisp        = Convert.ToInt32(txtOthers.Text);

            int result = 0;

            result = dispatchData.AddDispatchInfo(dispatch);
            if (result > 0)
            {
                divDanger.Visible   = false;
                divwarning.Visible  = false;
                divSusccess.Visible = true;
                lblSuccess.Text     = "Information Updated  Successfully";

                clearlist();
                ClearTextBox();
                generateDispatchSummary(id);
                //btnSubmitModal.Visible = false;
                // btnPrintSummary.Visible = true;
                pnlError.Update();

                upMain.Update();
            }
            else
            {
                divDanger.Visible   = false;
                divwarning.Visible  = true;
                divSusccess.Visible = false;
                lblwarning.Text     = "Please Contact to Site Admin";
                pnlError.Update();
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string confirmValue = Request.Form["confirm_value"];

            if (confirmValue == "Yes")
            {
                //ScriptManager.RegisterStartupScript(this, GetType(), "Close Modal Popup", "$('#myModal').modal('data-dismiss')", true);

                Dispatch     dispatch     = new Dispatch();
                DispatchData dispatchData = new DispatchData();

                DataSet ds = new DataSet();
                int     id = 0;
                string  nm = GlobalInfo.UserName.ToString();
                ds.ReadXml(Server.MapPath("~/Tabs/Dispatch/temp" + nm + ".xml"));
                ds.Tables[0].Columns.Add("DispatchInfoId", typeof(int));
                id = Convert.ToInt32(ds.Tables[1].Rows[0]["id"]);
                id = id + 1;
                for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
                {
                    ds.Tables[0].Rows[i]["DispatchInfoId"] = id;
                }
                Dispatch     disp     = new Dispatch();
                DispatchData dispData = new DispatchData();
                for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
                {
                    disp.OrderDetailsId = Convert.ToInt32(ds.Tables[0].Rows[i]["OrderDetailsID"]);

                    int x = dispData.UpdateDispatch(disp);
                    if (x > 0)
                    {
                        continue;
                    }
                    else
                    {
                        break;
                    }
                }

                string consString = ConfigurationManager.ConnectionStrings["projectConnection"].ConnectionString;
                using (SqlConnection con = new SqlConnection(consString))
                {
                    using (SqlBulkCopy sqlBulkCopy = new SqlBulkCopy(con))
                    {
                        //Set the database table name
                        sqlBulkCopy.DestinationTableName = "DispatchDetails";

                        //[OPTIONAL]: Map the DataTable columns with that of the database table
                        sqlBulkCopy.ColumnMappings.Add("DispatchInfoId", "DD_DispatchInfoId");
                        sqlBulkCopy.ColumnMappings.Add("OrderID", "DD_OrderId");
                        sqlBulkCopy.ColumnMappings.Add("OrderDetailsId", "DD_OrderDetailsId");
                        sqlBulkCopy.ColumnMappings.Add("Qty", "DD_NewQuantity");
                        sqlBulkCopy.ColumnMappings.Add("UnitCost", "UnitCost");
                        //sqlBulkCopy.ColumnMappings.Add("Country", "DD_OrderDetailsId");
                        con.Open();
                        sqlBulkCopy.WriteToServer(ds.Tables[0]);
                        con.Close();
                    }
                }

                dispatch.RouteID          = Convert.ToInt32(ds.Tables[0].Rows[0]["RouteID"]);
                dispatch.DispatchId       = id;
                dispatch.SalesmanFirstId  = Convert.ToInt32(dpSalesman.SelectedValue);
                dispatch.SalesmanSecondId = Convert.ToInt32(dpSalesman2.SelectedValue);
                dispatch.DriverFirstId    = Convert.ToInt32(dpDriver.SelectedValue);
                dispatch.DriverSecondId   = Convert.ToInt32(dpDriver2.SelectedValue);
                dispatch.VehicleId        = Convert.ToInt32(dpVehicle.SelectedValue);
                dispatch.Cartons          = (string.IsNullOrEmpty(txtCartons.Text) ? 0 : Convert.ToInt32(txtCartons.Text));
                dispatch.Trays            = (string.IsNullOrEmpty(txtTraysDispached.Text) ? 0 : Convert.ToInt32(txtTraysDispached.Text));
                dispatch.IceBox           = (string.IsNullOrEmpty(txtIceBox.Text) ? 0 : Convert.ToInt32(txtIceBox.Text));
                dispatch.OtherDisp        = (string.IsNullOrEmpty(txtOthers.Text) ? 0 : Convert.ToInt32(txtOthers.Text));
                dispatch.DispatchDate     = DateTime.Now.ToString("dd-MM-yyyy");
                dispatch.UserID           = GlobalInfo.Userid;
                dispatch.CategoryId       = Convert.ToInt32(dpCategory.SelectedItem.Value);
                dispatch.DispatchDateTime = DateTime.Now;
                int result = 0;
                result = dispatchData.AddDispatchInfo(dispatch);
                if (result > 0)
                {
                    divDanger.Visible   = false;
                    divwarning.Visible  = false;
                    divSusccess.Visible = true;
                    lblSuccess.Text     = "Information Updated  Successfully";

                    clearlist();
                    ClearTextBox();
                    updatestock(id);
                    generateDispatchSummary(id);
                    generateGatePass(id);
                    btnSubmitModal.Visible   = false;
                    btnPrintSummary.Visible  = true;
                    btnPrintGatePass.Visible = true;
                    pnlError.Update();

                    upMain.Update();
                }
                else
                {
                    divDanger.Visible   = false;
                    divwarning.Visible  = true;
                    divSusccess.Visible = false;
                    lblwarning.Text     = "Please Contact to Site Admin";
                    pnlError.Update();
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal();", true);
                //    //UpdatePanel1.Update();
                //    //this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked NO!')", true);
            }
        }