Пример #1
0
    protected void btnIngresar_Click(object sender, EventArgs e)
    {
        try
        {
            lblMessageError.Text = "";
            SessionController sessionController = new SessionController();
            SessionInfoModel  session           = new SessionInfoModel();
            SessionContent    content           = new SessionContent {
                CardCode = Request.Form["CardCode"], Password = Request.Form["Password"]
            };

            session = sessionController.SignIn(content);

            if (session != null)
            {
                Session["SessionInfo"]     = session;
                Session["SessionCardCode"] = session.cardcode;
                Session["SessionCardName"] = session.cardname;

                Response.Redirect("../../../Dashboard/Default.aspx", false);
            }
            else
            {
                Session["SessionInfo"]     = "";
                Session["SessionCardCode"] = "";
                Session["SessionCardName"] = "";
                lblMessageError.Text       = sessionController.messageError;
            }
        }
        catch (Exception ex)
        {
            lblMessageError.Text = ex.Message;
        }
    }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        lblMessageError.Text = "";

        if (IsPostBack)
        {
            return;
        }

        try
        {
            ComplementosController complementoController = new ComplementosController();
            SessionInfoModel       session = new SessionInfoModel();

            if (Session["SessionInfo"] == null || Session["SessionInfo"].ToString() == "")
            {
                Response.Redirect("../Identity/Account/Login/Default.aspx", false);
            }
            else
            {
                txtDate1.Text = Convert.ToDateTime(DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-01").ToShortDateString();
                txtDate2.Text = Convert.ToDateTime(DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month).ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Year.ToString()).ToShortDateString();

                session = (SessionInfoModel)Session["SessionInfo"];
                IEnumerable <PagosModel> pagos;
                pagos = complementoController.GetPagosEfectuados(session.cardcode, Convert.ToDateTime(txtDate1.Text), Convert.ToDateTime(txtDate2.Text));

                if (pagos != null)
                {
                    RadGrid1.DataSource = pagos;
                    RadGrid1.DataBind();
                }
                else
                {
                    RadGrid1.DataSource = null;
                    RadGrid1.DataBind();
                }

                Panel1.Visible        = true;
                Panel2.Visible        = false;
                btnPaso1Tab.BackColor = System.Drawing.Color.FromArgb(180, 192, 216);
                btnProcesar.Enabled   = false;
                AlertXMLError.Visible = false;
                AlertSuccess.Visible  = false;

                lblHidePathXML.Visible = false;
                lblHideUUIDXML.Visible = false;
            }
        }
        catch (Exception ex)
        {
            lblMessageError.Text = ex.Message;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        lblMessageError.Text = "";

        if (IsPostBack)
        {
            return;
        }

        try
        {
            if (Session["SessionInfo"] == null || Session["SessionInfo"].ToString() == "")
            {
                Response.Redirect("../Identity/Account/Login/Default.aspx", false);
            }
            else
            {
                SessionInfoModel    session   = new SessionInfoModel();
                ConsultasController consultas = new ConsultasController();
                session = (SessionInfoModel)Session["SessionInfo"];

                IEnumerable <PedidosModel> pedidos = consultas.GetPedidos(session.cardcode);
                if (pedidos != null)
                {
                    RadGridPedidos.DataSource = pedidos;
                    RadGridPedidos.DataBind();
                }

                Panel1.Visible        = true;
                Panel2.Visible        = false;
                Panel3.Visible        = false;
                btnPaso1.BackColor    = System.Drawing.Color.FromArgb(180, 192, 216);
                btnProcesar.Enabled   = false;
                AlertXMLError.Visible = false;
                AlertSuccess.Visible  = false;

                lblHidePathXML.Visible = false;
                lblHideUUIDXML.Visible = false;
            }
        }
        catch (Exception ex)
        {
            lblMessageError.Text = ex.Message;
        }
    }
        public ActionResult STSync(string fileid)
        {
            sTService = new STServices(siteuserid);
            SessionInfoModel sessionList = sTService.GetSessionInfo(fileid);

            //ViewBag.SessionList = sessionList;
            if (sessionList != null && sessionList.clientInfo != null)
            {
                bool issuccess = AddUpdateSaleztoolSync(fileid, sessionList);
                TempData["SaleztoolSyncSuccess"] = issuccess;
                TempData["SaleztoolSyncMessage"] = issuccess ? "Contact and project synced successfully" : "An error occoured! Please try again later";
            }
            else
            {
                TempData["SaleztoolSyncSuccess"] = false;
                TempData["SaleztoolSyncMessage"] = "No contact info available";
            }
            return(RedirectToAction("sessionfiles"));
        }
Пример #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            return;
        }

        try
        {
            lblMessageError.Text = "";

            ConsultasController consultasController = new ConsultasController();
            SessionInfoModel    session             = new SessionInfoModel();

            if (Session["SessionInfo"] == null || Session["SessionInfo"].ToString() == "")
            {
                Response.Redirect("../Identity/Account/Login/Default.aspx", false);
            }
            else
            {
                session = (SessionInfoModel)Session["SessionInfo"];

                IEnumerable <EntradasTdModel> entradas;
                entradas = consultasController.GetEntradasAbiertos(session.cardcode);

                if (entradas != null)
                {
                    RadGrid1.DataSource = entradas;
                    RadGrid1.DataBind();
                }
                else
                {
                    RadGrid1.DataSource = null;
                    RadGrid1.DataBind();
                }
            }
        }
        catch (Exception ex)
        {
            lblMessageError.Text = ex.Message;
        }
    }
Пример #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            return;
        }

        lblMessageError.Text = "";

        SessionInfoModel session = new SessionInfoModel();

        if (Session["SessionInfo"] == null || Session["SessionInfo"].ToString() == "")
        {
            Response.Redirect("../Identity/Account/Login/Default.aspx", false);
        }
        else
        {
            session = (SessionInfoModel)Session["SessionInfo"];

            this.ConsultarInfo();
        }
    }
Пример #7
0
    protected void ConsultarInfo()
    {
        try
        {
            lblMessageError.Text = "";


            ConsultasController consultas = new ConsultasController();
            SessionInfoModel    session   = new SessionInfoModel();

            session = (SessionInfoModel)Session["SessionInfo"];

            IEnumerable <PedidosModel> facturas = consultas.GetPedidos(session.cardcode);
            txtFacturas.Text = facturas != null?facturas.ToList().Count.ToString() : "0";

            string date1 = Convert.ToDateTime(DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-01").ToShortDateString();
            string date2 = Convert.ToDateTime(DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month).ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Year.ToString()).ToShortDateString();
            IEnumerable <PagosTdPagos> pagos = consultas.GetPagosEfectuadosOvpm(session.cardcode, Convert.ToDateTime(date1), Convert.ToDateTime(date2));
            txtPagos.Text = pagos != null?pagos.ToList().Count.ToString() : "0";

            IEnumerable <PedidosTdModel> pedidos = consultas.GetPedidosAbiertos(session.cardcode);
            txtPedidos.Text = pedidos != null?pedidos.ToList().Count.ToString() : "0";


            facturas  = null;
            pagos     = null;
            pedidos   = null;
            consultas = null;

            //throw new System.ArgumentException("Example message error: Parameter cannot be null", "original");
        }
        catch (Exception ex)
        {
            lblMessageError.Text = ex.Message;
        }
    }
Пример #8
0
 /// <summary>
 /// 点对点聊天消息
 /// </summary>
 public SessionInfoViewModel(AntSdkContact_User antsdkcontact_User, SessionInfoModel model, AntSdkMsgType msgType = AntSdkMsgType.ChatMsgText)
 {
     isPointOrGroup          = true;
     _SessionType            = SessionType.SingleChat;
     this.AntSdkContact_User = antsdkcontact_User;
     this.SessionId          = model.SessionId;
     this.MsgType            = msgType;
     //if (!string.IsNullOrWhiteSpace(model.photo))
     //{
     //    this.Photo = model.photo;
     //}
     //else
     //{
     //    this.Photo = "pack://application:,,,/AntennaChat;Component/Images/27-头像.png";
     //}
     this.Name = model.name;
     if (AntSdkContact_User.status == 0 && AntSdkContact_User.state == 0)
     {
         this.Name = model.name + "(停用)";
     }
     this.LastMessage   = model.lastMessage;
     this.LastChatIndex = model.lastChatIndex;
     SetUnreadCount(model.unreadCount);
     this.TopIndex = model.topIndex;
     if (string.IsNullOrWhiteSpace(model.lastTime))
     {
         this.LastTime = string.Empty;
     }
     else
     {
         try
         {
             this.LastTime         = DataConverter.FormatTimeByTimeStamp(model.lastTime);//从消息来的为时间戳
             this.LastMsgTimeStamp = model.lastTime;
         }
         catch
         {
             //this.LastTime = model.lastTime;//从Sqlite来的为时间格式
         }
     }
     //if (!string.IsNullOrEmpty(antsdkcontact_User.state))
     //{
     //    var state = int.Parse(antsdkcontact_User.state);
     if (AntSdkService.AntSdkCurrentUserInfo.robotId == AntSdkContact_User?.userId)
     {
         antsdkcontact_User.state = (int)GlobalVariable.OnLineStatus.OnLine;
     }
     if (!AntSdkService.AntSdkIsConnected)
     {
         UserOnlineStateIcon = "";
     }
     else if (antsdkcontact_User.state != (int)GlobalVariable.OnLineStatus.OffLine)
     {
         if (UserOnlineSataeInfo.UserOnlineStateIconDic.ContainsKey(antsdkcontact_User.state))
         {
             UserOnlineStateIcon = UserOnlineSataeInfo.UserOnlineStateIconDic[antsdkcontact_User.state];
         }
     }
     //}
     SetContactPhoto();
 }
Пример #9
0
    protected void btnProcesar_Click(object sender, EventArgs e)
    {
        try
        {
            AlertSuccess.Visible   = false;
            lblMessageCreate.Text  = "";
            lblMessageSuccess.Text = "";
            lblMessageError.Text   = "";

            int docEntry = 0;
            foreach (Telerik.Web.UI.GridDataItem dataitem in RadGrid1.Items)
            {
                if ((dataitem.FindControl("CheckBox1") as CheckBox).Checked == true)
                {
                    docEntry = int.Parse(dataitem["DocEntry"].Text);
                }
            }

            SessionInfoModel       session      = new SessionInfoModel();
            ComplementosController complementos = new ComplementosController();

            session = (SessionInfoModel)Session["SessionInfo"];

            PagosModel pagos = new PagosModel
            {
                CardCode    = session.cardcode,
                CardName    = session.cardname,
                DocCurr     = "",
                DocDate     = "",
                DocEntry    = docEntry,
                DocNum      = int.Parse(lblDocNum.Text),
                DocTotal    = 0,
                lmUUID      = lblHideUUIDXML.Text,
                lmAttachXML = lblHidePathXML.Text
            };

            SAPB1Result result1 = complementos.UpdateOvpm(pagos);
            if (result1 != null)
            {
                if (result1.Status == "Error")
                {
                    lblMessageError.Text = result1.Messages;
                }
                else
                {
                    lblMessageSuccess.Text = result1.Messages;
                    lblMessageCreate.Text  = result1.Messages;
                    AlertSuccess.Visible   = true;

                    btnPaso1Tab.Enabled = false;
                    btnPaso2Tab.Enabled = false;

                    btnValidar.Enabled  = false;
                    btnProcesar.Enabled = false;
                }
            }
            else
            {
                lblMessageSuccess.Text = "Ocurrio un problema al intentar procesar el archivo XML.";
            }
            complementos = null;
        }
        catch (Exception ex)
        {
            lblMessageError.Text = ex.Message;
        }
    }
Пример #10
0
    protected void btnValidar_Click(object sender, EventArgs e)
    {
        try
        {
            lblMessageError.Text    = "";
            lblMessageSuccess.Text  = "";
            lblMessageXmlError.Text = "";
            AlertXMLError.Visible   = false;

            double docTotal = 0;
            foreach (Telerik.Web.UI.GridDataItem dataitem in RadGrid1.Items)
            {
                if ((dataitem.FindControl("CheckBox1") as CheckBox).Checked == true)
                {
                    docTotal = Convert.ToDouble(dataitem["DocTotal"].Text);
                }
            }

            if (RadAsyncUpload1.UploadedFiles.Count > 0)
            {
                foreach (UploadedFile file in RadAsyncUpload1.UploadedFiles)
                {
                    if (file.FileName != "")
                    {
                        XMLController xmlController = new XMLController();
                        UploadResult  result        = xmlController.UploadFiles(file);
                        if (result.count > 0)
                        {
                            SessionInfoModel session = new SessionInfoModel();
                            session = (SessionInfoModel)Session["SessionInfo"];

                            InfoXML info = new InfoXML {
                                cardcode = session.cardcode, docnum = int.Parse(lblDocNum.Text), doctotal = docTotal, typedocument = "PA", xml = result.path
                            };
                            XMLResult xmlResult = xmlController.GetResultXML(info);

                            if (xmlResult.Status == "Error")
                            {
                                AlertXMLError.Visible   = true;
                                lblMessageXmlError.Text = xmlResult.Messages;
                                lblXmlFile.Text         = "";
                            }
                            else
                            {
                                lblHidePathXML.Text    = result.path;
                                lblHideUUIDXML.Text    = xmlResult.UUID;
                                lblXmlFile.Text        = file.FileName;
                                lblMessageSuccess.Text = xmlResult.Messages;
                                btnProcesar.Enabled    = true;
                            }
                        }
                        else
                        {
                            lblMessageError.Text = "Debe seleccionar un archivo XML.";
                            lblXmlFile.Text      = "";
                        }
                    }
                }
            }
            else
            {
                lblMessageError.Text = "Debe seleccionar un archivo XML.";
                lblXmlFile.Text      = "";
            }
        }
        catch (Exception ex)
        {
            lblMessageError.Text = ex.Message;
        }
    }
        public bool AddUpdateSaleztoolSync(string fileid, SessionInfoModel Sessioninfo)
        {
            bool ret = false;

            try
            {
                STClientModel info = Sessioninfo.clientInfo;
                if (info != null)
                {
                    CoContacts contact = db.CoContacts.Where(s => (s.ContactFirstName == null ? "" : s.ContactFirstName).Trim().ToLower() == info.firstName.Trim().ToLower() && (s.ContactLastName == null ? "" : s.ContactLastName).Trim().ToLower() == info.lastName.Trim().ToLower()).FirstOrDefault();
                    if (contact != null)
                    {
                        contact.ApiLinkID = fileid;// info.otherField == null ? "" : info.otherField;
                        db.SaveChanges();
                    }
                    else
                    {
                        string firstName    = info.firstName == null ? "" : info.firstName.Trim();
                        string lastName     = info.lastName == null ? "" : info.lastName.Trim();
                        string otherField   = fileid;//info.otherField == null ? "" : info.otherField.Trim();
                        string address1     = info.homeAddress == null ? "" : info.homeAddress.Street == null ? "" : info.homeAddress.Street.Trim();
                        string City         = info.homeAddress == null ? "" : info.homeAddress.City == null ? "" : info.homeAddress.City.Trim();
                        string Zip          = info.homeAddress == null ? "" : info.homeAddress.Zip == null ? "" : info.homeAddress.Zip.Trim();
                        string State        = info.homeAddress == null ? "" : info.homeAddress.State == null ? "" : info.homeAddress.State.Trim();
                        string emailAddress = info.emailAddress == null ? "" : info.emailAddress.Trim();
                        string Phone        = info.homeAddress == null ? "" : info.homeAddress.Phone == null ? "" : info.homeAddress.Phone.Trim();
                        db.InsertSalezToolzCustomer(siteusercompanyid, firstName, lastName, siteuserid, siteuserid, otherField, address1, City, State, Zip, emailAddress, Phone);
                        //Get Contact
                        contact = db.CoContacts.Where(s => (s.ContactFirstName == null ? "" : s.ContactFirstName).Trim().ToLower() == firstName.ToLower() && (s.ContactLastName == null ? "" : s.ContactLastName).Trim().ToLower() == lastName.ToLower()).FirstOrDefault();
                    }
                    //Project for contact
                    if (contact != null)
                    {
                        string projectname = info.fileName == null ? "" : info.fileName.Trim();
                        if (projectname != "")
                        {
                            ProjectInfo project = db.ProjectInfo.Where(s => (s.ProjectName == null ? "" : s.ProjectName).Trim().ToLower() == projectname.ToLower()).FirstOrDefault();
                            if (project != null)
                            {
                                project.ApiLinkID = fileid;// info.otherField == null ? "" : info.otherField;
                                db.SaveChanges();
                            }
                            else
                            {
                                string   otherField   = fileid;//info.otherField == null ? "" : info.otherField.Trim();
                                string   address1     = info.workAddress == null ? "" : info.workAddress.Street == null ? "" : info.workAddress.Street.Trim();
                                string   City         = info.workAddress == null ? "" : info.workAddress.City == null ? "" : info.workAddress.City.Trim();
                                string   Zip          = info.workAddress == null ? "" : info.workAddress.Zip == null ? "" : info.workAddress.Zip.Trim();
                                string   State        = info.workAddress == null ? "" : info.workAddress.State == null ? "" : info.workAddress.State.Trim();
                                string   emailAddress = info.emailAddress == null ? "" : info.emailAddress.Trim();
                                string   Phone        = info.workAddress == null ? "" : info.workAddress.Phone == null ? "" : info.workAddress.Phone.Trim();
                                DateTime startdate    = info.createDate == null ? DateTime.Now : info.createDate;

                                //tax info
                                bool    istax          = Sessioninfo.taxProfile != null;
                                string  taxCode        = !istax ? "" : Sessioninfo.taxProfile.taxName == null ? "" : Sessioninfo.taxProfile.taxName.Trim();
                                string  taxDescription = (istax && Sessioninfo.taxProfile.taxes != null && Sessioninfo.taxProfile.taxes.Count > 0) ? Sessioninfo.taxProfile.taxes[0].applyType == null ? "" : Sessioninfo.taxProfile.taxes[0].applyType : "";
                                decimal salesrate_dec  = (istax && Sessioninfo.taxProfile.taxes != null && Sessioninfo.taxProfile.taxes.Count > 0) ? Sessioninfo.taxProfile.taxes[0].value == null ? 0 : ExtractDecimalFromString(Sessioninfo.taxProfile.taxes[0].value) : 0;
                                //decimal salesrate_dec = 0;
                                //decimal.TryParse(salesrate, out salesrate_dec);

                                //Adjustment
                                bool          isadjust           = Sessioninfo.adjustment != null;
                                decimal       equipAdjust        = 0;
                                string        equipAdjustLabel   = "";
                                decimal       laborAdjust        = 0;
                                string        laborAdjustLabel   = "";
                                decimal       otherAdjust        = 0;
                                string        otherAdjustLabel   = "";
                                string        otherAdjustType    = "";
                                decimal       profileAdjust      = 0;
                                string        profileAdjustLabel = "";
                                string        profileAdjustType  = "";
                                StringBuilder projectItems       = new StringBuilder();
                                if (isadjust)
                                {
                                    equipAdjust      = Sessioninfo.adjustment.equipment == null ? 0 : ExtractDecimalFromString(Sessioninfo.adjustment.equipment.Trim());
                                    equipAdjustLabel = Sessioninfo.adjustment.equipmentLabel == null ? "" : Sessioninfo.adjustment.equipmentLabel.Trim();
                                    laborAdjust      = Sessioninfo.adjustment.labor == null ? 0 : ExtractDecimalFromString(Sessioninfo.adjustment.labor.Trim());
                                    laborAdjustLabel = Sessioninfo.adjustment.laborLabel == null ? "" : Sessioninfo.adjustment.laborLabel.Trim();
                                    otherAdjust      = Sessioninfo.adjustment.otherDiscountValue == null ? 0 : ExtractDecimalFromString(Sessioninfo.adjustment.otherDiscountValue.Trim());
                                    otherAdjustLabel = Sessioninfo.adjustment.otherDiscountLabel == null ? "" : Sessioninfo.adjustment.otherDiscountLabel.Trim();
                                    otherAdjustType  = Sessioninfo.adjustment.discountType == null ? "" : Sessioninfo.adjustment.discountType.Trim();
                                    //profileAdjust = Sessioninfo.adjustment.equipment == null ? 0 : ExtractDecimalFromString(Sessioninfo.adjustment.equipment.Trim());
                                }

                                if (Sessioninfo.selectedPackages != null && Sessioninfo.selectedPackages.Count > 0)
                                {
                                    projectItems.Append("<ArrayProjectItems>");
                                    foreach (STPackageModel package in Sessioninfo.selectedPackages)
                                    {
                                        projectItems.Append("<ProjectItem>");
                                        projectItems.Append("<SiteUserID>" + siteuserid + "</SiteUserID>");
                                        projectItems.Append("<GroupName>" + SetValueForXML(package.packageGroupName) + "</GroupName>");
                                        projectItems.Append("<ManufacturerName>" + SetValueForXML(package.manufacturer) + "</ManufacturerName>");
                                        projectItems.Append("<ContactCoName>" + SetValueForXML(package.vendor) + "</ContactCoName>");
                                        projectItems.Append("<Model>" + SetValueForXML(package.packageName) + "</Model>");
                                        projectItems.Append("<SKU>" + SetValueForXML(package.sku) + "</SKU>");
                                        projectItems.Append("<ProductDescription>" + SetValueForXML(package.description) + "</ProductDescription>");
                                        projectItems.Append("<SalesDescription>" + SetValueForXML(package.description) + "</SalesDescription>");
                                        //projectItems.Append("<ProductDescription></ProductDescription>");
                                        //projectItems.Append("<SalesDescription></SalesDescription>");
                                        projectItems.Append("<Hyperlink></Hyperlink>");
                                        projectItems.Append("<StageName>" + SetValueForXML(package.phase) + "</StageName>");
                                        projectItems.Append("<SalesTaxed>" + (SetValueForXML(package.taxable).Trim().ToLower() == "yes" ? "True" : "False") + "</SalesTaxed>");
                                        projectItems.Append("<Cost>" + SetDecimalValueForXML(package.cost) + "</Cost>");
                                        projectItems.Append("<Price>" + SetDecimalValueForXML(package.equipment) + "</Price>");
                                        projectItems.Append("<DivisionName>" + SetValueForXML(package.packageGroupName) + "</DivisionName>");
                                        if (package.roomsQuantity != null && package.roomsQuantity.Count > 0)
                                        {
                                            projectItems.Append("<Qty>" + SetDecimalValueForXML(package.roomsQuantity[0].quantity) + "</Qty>");
                                        }
                                        else
                                        {
                                            projectItems.Append("<Qty>1</Qty>");
                                        }
                                        projectItems.Append("<EstHrs>" + (SetDecimalValueForXML(package.labor1Hours) <= 0 ? 1 : SetDecimalValueForXML(package.labor1Hours)) + "</EstHrs>");
                                        projectItems.Append("<StageLabor1Cost>" + SetDecimalValueForXML(package.labor1HourlyRateCost) + "</StageLabor1Cost>");
                                        projectItems.Append("<StageLabor1Price>" + SetDecimalValueForXML(package.labor1HourlyRate) + "</StageLabor1Price>");
                                        projectItems.Append("<StageLabor2Cost>" + SetDecimalValueForXML(package.labor2HourlyRateCost) + "</StageLabor2Cost>");
                                        projectItems.Append("<StageLabor2Price>" + SetDecimalValueForXML(package.labor2HourlyRate) + "</StageLabor2Price>");
                                        projectItems.Append("<Labor1Cost>" + SetDecimalValueForXML(package.labor1Cost) + "</Labor1Cost>");
                                        projectItems.Append("<Labor1Price>" + SetDecimalValueForXML(package.labor1Price) + "</Labor1Price>");
                                        projectItems.Append("<Labor2Cost>" + SetDecimalValueForXML(package.labor2Cost) + "</Labor2Cost>");
                                        projectItems.Append("<Labor2Price>" + SetDecimalValueForXML(package.labor2Price) + "</Labor2Price>");
                                        projectItems.Append("<ModelLabor1>" + SetValueForXML(package.packageName) + " Labor 1</ModelLabor1>");
                                        projectItems.Append("<ModelLabor2>" + SetValueForXML(package.packageName) + " Labor 2</ModelLabor2>");
                                        projectItems.Append("</ProjectItem>");
                                    }
                                    projectItems.Append("</ArrayProjectItems>");
                                }

                                db.InsertSalezToolzProjectInfo(siteusercompanyid, 5 /*projecttypeid*/, projectname, contact.ContactID, address1, City, State, Zip, startdate, Phone, emailAddress, siteuserid /*salesid*/, otherField, taxCode, taxDescription, salesrate_dec, equipAdjust, equipAdjustLabel, laborAdjust, laborAdjustLabel, otherAdjust, otherAdjustLabel, otherAdjustType, profileAdjust, profileAdjustLabel, profileAdjustType, projectItems.ToString());
                            }
                        }
                    }
                }
                ret = true;
            }
            catch (Exception ex)
            {
                ret = false;
                //throw ex;
            }
            return(ret);
        }
    protected void btnProcesar_Click(object sender, EventArgs e)
    {
        try
        {
            AlertSuccess.Visible   = false;
            lblMessageCreate.Text  = "";
            lblMessageSuccess.Text = "";
            lblMessageError.Text   = "";

            if (lblHideUUIDXML.Text != "")
            {
                SessionInfoModel    session  = new SessionInfoModel();
                List <FacturaModel> facturas = new List <FacturaModel>();

                session = (SessionInfoModel)Session["SessionInfo"];

                foreach (Telerik.Web.UI.GridDataItem dataitem in RadGridPartidas.Items)
                {
                    if ((dataitem.FindControl("CheckBox1") as CheckBox).Checked == true)
                    {
                        facturas.Add(new FacturaModel {
                            DocNumPedido   = 0,
                            DocEntryPedido = int.Parse(dataitem["DocEntryPedido"].Text),
                            DocEntry       = int.Parse(dataitem["DocEntry"].Text),
                            DocNum         = int.Parse(dataitem["DocNum"].Text),
                            SeriesName     = "",
                            DocType        = dataitem["DocType"].Text,
                            CardCode       = session.cardcode,
                            CardName       = session.cardname,
                            DocDate        = "",
                            DocDueDate     = "",
                            NumAtCard      = "",
                            DocCur         = dataitem["Currency"].Text,
                            Rounding       = "",
                            Comments       = "",
                            Address2       = "",
                            RoundDif       = 0,
                            SubTotal       = 0,
                            VatSum         = 0,
                            DocTotal       = 0,
                            LineNum        = int.Parse(dataitem["LineNum"].Text),
                            ItemCode       = dataitem["ItemCode"].Text,
                            Dscription     = dataitem["Dscription"].Text,
                            Quantity       = Convert.ToDouble(dataitem["Quantity"].Text),
                            OpenQty        = 0,
                            OpenCreQty     = Convert.ToDouble(dataitem["OpenCreQty"].Text),
                            Price          = Convert.ToDouble(dataitem["Price"].Text),
                            DiscPrcnt      = Convert.ToDouble(dataitem["DiscPrcnt"].Text),
                            Currency       = dataitem["Currency"].Text,
                            unitMsr        = "",
                            WhsCode        = "",
                            VatPrcnt       = Convert.ToDouble(dataitem["VatPrcnt"].Text),
                            ShipDate       = "",
                            SlpCode        = 0,
                            FreeTxt        = "",
                            LineTotal      = Convert.ToDouble(dataitem["LineTotal"].Text),
                            VatSumLine     = Convert.ToDouble(dataitem["VatSumLine"].Text),
                            lmUUID         = lblHideUUIDXML.Text,
                            lmAttachXML    = lblHidePathXML.Text
                        });
                    }
                }

                if (facturas.Count > 0)
                {
                    FacturasController facturasController = new FacturasController();
                    SAPB1Result        result             = facturasController.CreateOpch(facturas);
                    if (result.Status == "Ok")
                    {
                        lblMessageSuccess.Text = result.Messages;
                        lblMessageCreate.Text  = result.Messages;
                        AlertSuccess.Visible   = true;

                        btnPaso1.Enabled = false;
                        btnPaso2.Enabled = false;
                        btnPaso3.Enabled = false;

                        btnValidar.Enabled  = false;
                        btnProcesar.Enabled = false;
                    }
                    else
                    {
                        lblMessageError.Text = result.Messages;
                    }
                    facturasController = null;
                }
                else
                {
                    lblMessageError.Text = "Ocurrio un problema al intentar recuerar la información de las partidas seleccionadas.";
                }
            }
            else
            {
                lblMessageError.Text = "Ocurrio un problema con la validación del archivo XML.";
            }
        }
        catch (Exception ex)
        {
            lblMessageError.Text = ex.Message;
        }
    }