Ejemplo n.º 1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            using (LinqToSqlDataContext db = new LinqToSqlDataContext())
            {
                EM_ProductParam productParameters = new EM_ProductParam();
                if (!chkAsNew.Checked)
                {
                    int paramID = 0;
                    int.TryParse(gvEMParams.SelectedValue.ToString(), out paramID);
                    productParameters = db.EM_ProductParams.Where(x => x.EM_ProductParamID == paramID).FirstOrDefault();

                    if (productParameters == null)
                    {
                        lblErrorMsg.Text = "Record not found to update.";
                        return;
                    }
                }

                productParameters.EM_ProductBillingDesc       = txtBillingDesc.Text;
                productParameters.EM_ProductBillingCommitment = Convert.ToInt32(txtBillingCommit.Text);

                productParameters.EM_CoreService             = Convert.ToInt32(txtCoreService.Text);
                productParameters.EM_CoreType                = Convert.ToInt32(txtCoreType.Text);
                productParameters.EM_InstType_Equivalent     = txtInstTypeEquiv.Text;
                productParameters.EM_CorePrimaryCluster      = Convert.ToInt32(txtPriCluster.Text);
                productParameters.EM_CorePrimarySubCluster   = Convert.ToInt32(txtPriSubcluster.Text);
                productParameters.EM_CoreSecondaryCluster    = Convert.ToInt32(txtSecondarycluster.Text);
                productParameters.EM_CoreSecondarySubCluster = Convert.ToInt32(txtSecondarySubCluster.Text);
                productParameters.EM_InstType_Type           = Convert.ToInt32(txtTypeID.Text);
                string username = SiteUtility.GetUserName();
                productParameters.EM_ModifiedBy   = username;
                productParameters.EM_ModifiedOn   = DateTime.Now;
                productParameters.Is_Deleted_Flag = chkDeleteFlag.Checked;

                if (chkAsNew.Checked)
                {
                    productParameters.EM_CreatedBy = username;
                    productParameters.EM_CreatedOn = DateTime.Now;
                    db.EM_ProductParams.InsertOnSubmit(productParameters);
                }

                db.SubmitChanges();
                ResetForm();
                gvEMParams.DataBind();
                divForm.Visible = false;
            }
        }
        catch (Exception exp)
        {
            lblErrorMsg.Text = exp.Message;
        }
    }
    public static string GetOrderInfo(int orderid)
    {
        string orderData = "";

        try
        {
            using (LinqToSqlDataContext db = new LinqToSqlDataContext())
            {
                var orderItemsWithEM = db.USP_GetEmizonOrderItems(orderid);
                var data             = orderItemsWithEM.Select(x =>
                                                               new
                {
                    ProductCode = x.ProductCode,
                    ProductDesc = x.ProductName,
                    EMNO        = string.IsNullOrEmpty(x.EM_No) ? "" : x.EM_No,
                    InstallID   = x.GPRSNo,
                    //EMNo = "EMNo: " + x.EM_No + (string.IsNullOrEmpty(x.GPRSNo) ? "" : ", InstallID: " + x.GPRSNo), //only show installid if available as not all ARC's has this feature
                    SerialNo          = string.IsNullOrEmpty(x.EM_TCD_SerialNo) ? "N/A" : x.EM_TCD_SerialNo,
                    EM_APIMsg         = string.IsNullOrEmpty(x.EM_APIMsg) ? "" :  x.EM_APIMsg,
                    EM_APIStatusID    = x.EM_APIStatusID.HasValue ? x.EM_APIStatusID.ToString() : "",
                    OrderItemDetailId = x.OrderItemDetailId,
                }
                                                               ).ToList();

                Newtonsoft.Json.JsonSerializer jsr = new Newtonsoft.Json.JsonSerializer();
                System.IO.StringWriter         sw  = new System.IO.StringWriter();
                Newtonsoft.Json.JsonTextWriter jtw = new Newtonsoft.Json.JsonTextWriter(sw);
                jsr.Serialize(jtw, data.ToArray());
                orderData = sw.ToString();
            }
        }
        catch (Exception objException)
        {
            try
            {
                CSLOrderingARCBAL.LinqToSqlDataContext db;
                db = new CSLOrderingARCBAL.LinqToSqlDataContext();
                db.USP_SaveErrorDetails("OrderconfirmationEmizon", "LoadEmizonOrderData", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException),
                                        Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, SiteUtility.GetUserName());
            }
            catch { }
        }
        return(orderData);
    }
    private void LoadOrderData()
    {
        try
        {
            int orderid = 0;
            int.TryParse(hdnOrderID.Value, out orderid);

            using (LinqToSqlDataContext db = new LinqToSqlDataContext())
            {
                var order = db.Orders.Where(x => x.OrderId == orderid).FirstOrDefault();
                if (order != null)
                {
                    lblOrderNumber.Text = "CSL" + order.OrderNo;
                    lblOrderRef.Text    = order.OrderRefNo;
                }

                //var orderItemsWithEM = db.USP_GetEmizonOrderItems(orderid);
                //var data = orderItemsWithEM.Select(x =>
                //    new
                //    {
                //        ProductCode = x.ProductCode,
                //        ProductDesc = x.ProductName,
                //        EMNO = "EMNo: " + x.EM_No + (string.IsNullOrEmpty(x.GPRSNo) ? "" : ", InstallID: " + x.GPRSNo), //only show installid if available as not all ARC's has this feature
                //        SerialNo = string.IsNullOrEmpty(x.EM_TCD_SerialNo) ? "N/A" : x.EM_TCD_SerialNo,
                //    }
                //    );
                //gvOrderItems.DataSource = data;
                //gvOrderItems.DataBind();
            }
        }
        catch (Exception objException)
        {
            try
            {
                CSLOrderingARCBAL.LinqToSqlDataContext db;
                db = new CSLOrderingARCBAL.LinqToSqlDataContext();
                db.USP_SaveErrorDetails(Request.Url.ToString(), "LoadEmizonOrderData", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException),
                                        Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, SiteUtility.GetUserName());
            }
            catch { }
        }
    }
    public static int UpdateInstallID(string InstallID, string OrderItemDetailID, string OrderID)
    {
        try
        {
            using (LinqToSqlDataContext db = new LinqToSqlDataContext())
            {
                string emizonQueuePath = ConfigurationManager.AppSettings["EmizonQueue"].ToString();

                var OrderItemDetails = db.OrderItemDetails.Where(i => i.OrderItemDetailId == Convert.ToInt32(OrderItemDetailID)).SingleOrDefault();

                OrderItemDetails.GPRSNo = InstallID;
                db.SubmitChanges();

                EmizonOrderController.AddAPIRequestToQueue(emizonQueuePath, new Emizon.APIModels.MSMQTypes.QueueOrderMessage()
                {
                    orderID = Convert.ToInt32(OrderID)
                });

                return(0);
            }
        }
        catch (Exception objException)
        {
            try
            {
                CSLOrderingARCBAL.LinqToSqlDataContext db;
                db = new CSLOrderingARCBAL.LinqToSqlDataContext();
                db.USP_SaveErrorDetails("UpdateInstallID", "UpdateInstallID", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException),
                                        Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, SiteUtility.GetUserName());
                return(-1);
            }
            catch {
                return(-1);
            }
        }
    }
Ejemplo n.º 5
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            try
            {
                Audit  audit   = new Audit();
                string ctgCode = "";
                if (!string.IsNullOrEmpty(txtctgCode.Text) && !string.IsNullOrEmpty(txtctgName.Text) &&
                    !string.IsNullOrEmpty(Txtlistorder.Text))
                {
                    int    chkgprs      = 0;
                    string defaultimg   = "";
                    string largeimg     = "";
                    string dbdefaultimg = "";
                    string dblargeimg   = "";
                    ctgCode = txtctgCode.Text.ToString();
                    db      = new LinqToSqlDataContext();

                    try
                    {
                        //if updating category and delete all the mapped arc's and products of this category.
                        #region existingCategory
                        if (Session[enumSessions.CategoryId.ToString()] != null)
                        {
                            var CatInfo = (from cat in db.Categories
                                           where cat.CategoryId == Convert.ToInt32(Session[enumSessions.CategoryId.ToString()])
                                           select cat).SingleOrDefault();
                            if (FileUpload1.HasFile)
                            {
                                string filenamewithoutext = System.IO.Path.GetFileNameWithoutExtension(FileUpload1.PostedFile.FileName);
                                string ext = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName);
                                string ff  = filenamewithoutext + txtctgCode.Text.ToString() + ext;
                                defaultimg = "../images/" + ff;
                                FileUpload1.SaveAs(Server.MapPath(defaultimg));
                                dbdefaultimg = "images/" + ff;
                            }
                            else
                            {
                                dbdefaultimg = CatInfo.DefaultImage;
                            }


                            if (FileUpload2.HasFile)
                            {
                                string filenamewithoutext = System.IO.Path.GetFileNameWithoutExtension(FileUpload2.PostedFile.FileName);
                                string ext = System.IO.Path.GetExtension(FileUpload2.PostedFile.FileName);
                                string ff  = filenamewithoutext + txtctgCode.Text.ToString() + ext;
                                largeimg = "../images/" + ff;
                                FileUpload2.SaveAs(Server.MapPath(largeimg));
                                dblargeimg = "images/" + ff;
                            }
                            else
                            {
                                dblargeimg = CatInfo.LargeImage;
                            }

                            if (CheckBoxgprschip.Checked == true)
                            {
                                chkgprs = 1;
                            }
                            else
                            {
                                chkgprs = 0;
                            }


                            var catg = db.CreateCategory(Convert.ToInt32(Session[enumSessions.CategoryId.ToString()].ToString()),
                                                         txtctgCode.Text.ToString(), txtctgName.Text.ToString(), txtctgdesc.Text.ToString(),
                                                         dbdefaultimg, dblargeimg, SiteUtility.GetUserName(),
                                                         Convert.ToBoolean(chkgprs), Convert.ToInt32(Txtlistorder.Text.ToString()),
                                                         chkIsDeleted.Checked, txtSalesType.Text).SingleOrDefault();

                            if (catg != null)
                            {
                                Session[enumSessions.CategoryId.ToString()] = catg.CategoryId;
                            }
                            if (catg.CategoryId == 0)
                            {
                                string script = "alertify.alert('" + ltrDuplCat.Text + "');";
                                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
                                MaintainScrollPositionOnPostBack = false;
                            }
                            else
                            {
                                string script = "alertify.alert('Category [" + txtctgCode.Text + "] - " + txtctgName.Text + " updated successfully.');";
                                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
                                MaintainScrollPositionOnPostBack = false;
                            }

                            audit.Notes = "CategoryId: " + Convert.ToInt32(Session[enumSessions.CategoryId.ToString()].ToString()) + ", Code: " + txtctgCode.Text.ToString() + ", Name: " + txtctgName.Text.ToString() + ", Description: " + txtctgdesc.Text.ToString() + ", DefaultImg: " + dbdefaultimg + ", LargeImg: " + dblargeimg + ", Allow GPRS: " + Convert.ToBoolean(chkgprs) + ", List Order: " + Convert.ToInt32(Txtlistorder.Text.ToString()) + ", Is Deleted: " + chkIsDeleted.Checked + ", Sales Types: " + txtSalesType.Text;
                        }
                        #endregion
                        #region newCategory
                        else
                        {
                            string filenamewithoutext1 = System.IO.Path.GetFileNameWithoutExtension(FileUpload1.PostedFile.FileName);
                            string ext1 = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName);
                            string ff1  = filenamewithoutext1 + txtctgCode.Text.ToString() + ext1;

                            string filenamewithoutext2 = System.IO.Path.GetFileNameWithoutExtension(FileUpload2.PostedFile.FileName);
                            string ext2 = System.IO.Path.GetExtension(FileUpload2.PostedFile.FileName);
                            string ff2  = filenamewithoutext2 + txtctgCode.Text.ToString() + ext2;
                            defaultimg = ff1;
                            largeimg   = ff2;
                            string defImgPath = "images/" + defaultimg;
                            string LImgPath   = "images/" + largeimg;
                            if (FileUpload1.HasFile)
                            {
                                FileUpload1.SaveAs(Server.MapPath("../images/" + defaultimg));
                            }
                            if (FileUpload2.HasFile)
                            {
                                FileUpload2.SaveAs(Server.MapPath("../images/" + largeimg));
                            }
                            if (CheckBoxgprschip.Checked == true)
                            {
                                chkgprs = 1;
                            }
                            else
                            {
                                chkgprs = 0;
                            }

                            var cats = db.CreateCategory(0, txtctgCode.Text.ToString().Trim(), txtctgName.Text.ToString().Trim(), txtctgdesc.Text.ToString().Trim(), defImgPath.ToString().Trim(), LImgPath.ToString().Trim(), SiteUtility.GetUserName(), Convert.ToBoolean(chkgprs), Convert.ToInt32(Txtlistorder.Text.ToString()), chkIsDeleted.Checked, txtSalesType.Text).Single();
                            if (cats != null)
                            {
                                Session[enumSessions.CategoryId.ToString()] = cats.CategoryId;
                            }
                            if (cats.CategoryId == 0)
                            {
                                string script = "alertify.alert('" + ltrDuplCat.Text + "');";
                                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
                                MaintainScrollPositionOnPostBack = false;
                            }
                            else
                            {
                                string script = "alertify.alert('Category [" + txtctgCode.Text + "] - " + txtctgName.Text + " created successfully.');";
                                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
                                MaintainScrollPositionOnPostBack = false;
                            }
                            audit.Notes = "CategoryId: " + cats.CategoryId.ToString() + ", Code: " + txtctgCode.Text.ToString() + ", Name: " + txtctgName.Text.ToString() + ", Description: " + txtctgdesc.Text.ToString() + ", DefaultImg: " + dbdefaultimg + ", LargeImg: " + dblargeimg + ", Allow GPRS: " + Convert.ToBoolean(chkgprs) + ", List Order: " + Convert.ToInt32(Txtlistorder.Text.ToString()) + ", Is Deleted: " + chkIsDeleted.Checked + ", Sales Types: " + txtSalesType.Text;
                        }
                        #endregion
                    }
                    catch (Exception exp)
                    {
                        db = new CSLOrderingARCBAL.LinqToSqlDataContext();
                        db.USP_SaveErrorDetails(Request.Url.ToString(), "btnSave_Click",
                                                Convert.ToString(exp.Message), Convert.ToString(exp.InnerException),
                                                Convert.ToString(exp.StackTrace), "",
                                                HttpContext.Current.Request.UserHostAddress, false,
                                                SiteUtility.GetUserName());
                    }

                    //enter all the checked products of this category
                    audit.Notes += "ProductID: ";
                    List <Category_Product_Map> categoryProductDbRows = new List <Category_Product_Map>();
                    foreach (GridViewRow ctgrow in gvctg.Rows)
                    {
                        if (ctgrow.RowType == DataControlRowType.DataRow)
                        {
                            GridView innergrid = ctgrow.FindControl("gvinner") as GridView;
                            foreach (GridViewRow prodrow in innergrid.Rows)
                            {
                                if (prodrow.RowType == DataControlRowType.DataRow)
                                {
                                    CheckBox             chkpro = prodrow.FindControl("chkprod") as CheckBox;
                                    Category_Product_Map cmp;
                                    if (chkpro.Checked == true)
                                    {
                                        int Prodid = int.Parse(innergrid.DataKeys[prodrow.RowIndex].Value.ToString());
                                        cmp            = new Category_Product_Map();
                                        cmp.CategoryId = Convert.ToInt32(Session[enumSessions.CategoryId.ToString()]);
                                        cmp.ProductId  = Convert.ToInt32(Prodid);
                                        var count = categoryProductDbRows.Where(x => x.CategoryId == cmp.CategoryId && x.ProductId == cmp.ProductId).Count();
                                        if (count <= 0)
                                        {
                                            categoryProductDbRows.Add(cmp);
                                        }
                                        audit.Notes += Prodid + ", ";
                                    }
                                }
                            }
                        }
                    }
                    db.Category_Product_Maps.InsertAllOnSubmit(categoryProductDbRows);
                    db.SubmitChanges();


                    //enter all the checked Arc's of this category
                    audit.Notes += "ARCId: ";

                    var Checkedarc = (from ListItem item in CheckBoxARC.Items where item.Selected select item.Value).ToList();
                    if (Checkedarc.Any())
                    {
                        ARC_Category_Map acm;
                        int        catid = Convert.ToInt32(Session[enumSessions.CategoryId.ToString()]);
                        List <int> arcs  = new List <int>();
                        foreach (String chkarc in Checkedarc)
                        {
                            if (chkarc != "Select All")
                            {
                                acm            = new ARC_Category_Map();
                                acm.CategoryId = catid;
                                acm.ARCId      = Convert.ToInt32(chkarc);
                                if (arcs.IndexOf(acm.ARCId) < 0)
                                {
                                    db.ARC_Category_Maps.InsertOnSubmit(acm);
                                    db.SubmitChanges();
                                }
                                arcs.Add(acm.ARCId);

                                audit.Notes += chkarc + ",";
                            }
                        }
                    }

                    pnlcategorydetail.Visible = false;
                    pnlcategorylist.Visible   = true;
                    LoadData();
                }
                else
                {
                    string script = "alertify.alert('" + ltrRequired.Text + "');";
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
                }

                MaintainScrollPositionOnPostBack = false;


                audit.UserName  = Session[enumSessions.User_Name.ToString()].ToString();
                audit.ChangeID  = Convert.ToInt32(enumAudit.Manage_Category);
                audit.CreatedOn = DateTime.Now;
                if (Request.ServerVariables["LOGON_USER"] != null)
                {
                    audit.WindowsUser = Request.ServerVariables["LOGON_USER"];
                }
                audit.IPAddress = Request.UserHostAddress;
                db.Audits.InsertOnSubmit(audit);
                db.SubmitChanges();
            }
            catch (Exception objException)
            {
                db = new CSLOrderingARCBAL.LinqToSqlDataContext();
                db.USP_SaveErrorDetails(Request.Url.ToString(), "btnSave_Click", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, Convert.ToString(HttpContext.Current.Session[enumSessions.User_Id.ToString()]));
            }
        }
        else
        {
            string script = "alertify.alert('" + ltrRequired.Text + "');";
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
            MaintainScrollPositionOnPostBack = false;
        }
    }
Ejemplo n.º 6
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        try
        {
            db = new LinqToSqlDataContext();
            var searchbyname = (from cats in db.Categories
                                where cats.IsDeleted == false &&
                                (cats.CategoryName.Contains(txtctgnamesrch.Text.Trim()) && cats.CategoryCode.Contains(txtctgcodesrch.Text.Trim()))
                                select cats);

            if (searchbyname.Count() != 0)
            {
                gvCategories.DataSource = searchbyname;
                gvCategories.DataBind();
            }
            else
            {
                LoadData();
            }

            ClearAllInputs();

            //uncheck arcs
            for (int i = 0; i <= CheckBoxARC.Items.Count - 1; i++)
            {
                CheckBoxARC.Items[i].Selected = false;
            }
        }
        catch (Exception objException)
        {
            db = new CSLOrderingARCBAL.LinqToSqlDataContext();
            db.USP_SaveErrorDetails(Request.Url.ToString(), "btnSearch_Click", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, SiteUtility.GetUserName());
        }
    }
Ejemplo n.º 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         try
         {
             LoadData();
             Session[enumSessions.CategoryId.ToString()] = null;
         }
         catch (Exception objException)
         {
             db = new CSLOrderingARCBAL.LinqToSqlDataContext();
             db.USP_SaveErrorDetails(Request.Url.ToString(), "Page_Load", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, SiteUtility.GetUserName());
         }
     }
 }