当前位置: 首页>>代码示例>>C#>>正文


C# Customers.saveCustomer方法代码示例

本文整理汇总了C#中Customers.saveCustomer方法的典型用法代码示例。如果您正苦于以下问题:C# Customers.saveCustomer方法的具体用法?C# Customers.saveCustomer怎么用?C# Customers.saveCustomer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Customers的用法示例。


在下文中一共展示了Customers.saveCustomer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Button1_Click

    /// <summary>
    /// Edits the current Customer and makes the validations.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button1_Click(object sender, EventArgs e)
    {
        int idCustomer = Convert.ToInt16(HiddenField1.Value);
        string Name = Security.cleanSQL(TextBox1.Text);
        string LastName = Security.cleanSQL(TextBox2.Text);
        string Email = Security.cleanSQL(TextBox3.Text);
        string RFC = Security.cleanSQL(TextBox4.Text);
        int nAddresses = Convert.ToInt16(Page.Request["nAddresses"]);
        ArrayList listOfValidAddresses = new ArrayList();
        Boolean flag = false;

        try
        {
            int j = 1;
            for (int i = 0; i < nAddresses; i++)
            {
                string[] data = new string[2];

                if (Page.Request["Address" + j.ToString()] != "")
                {
                    data[0] = Security.cleanSQL(Page.Request["Address" + j.ToString()].ToString());
                    if (Page.Request["Phone" + j.ToString()] != "")
                    {
                        data[1] = Security.cleanSQL(Page.Request["Phone" + j.ToString()].ToString());
                        if (Security.isPhone(data[1]))
                        {
                            listOfValidAddresses.Add(data);
                            flag = true;
                        }
                        else
                        {
                            data[1] = "";
                            listOfValidAddresses.Add(data);
                            throw new Exception("1");
                        }
                    }
                    else
                    {
                        data[1] = "";
                        listOfValidAddresses.Add(data);
                        flag = true;
                    }
                }
                j++;
            }
        }
        catch (Exception ex)
        {
            if (ex.Message == "1")
            {
                this.setNotification("warning", "¡Teléfono Inválido!", "El teléfono ingresado no es válido... El formato correcto es LADA+TELEFONO, ejemplo: 31400000");
                flag = false;
            }
        }

        if (Security.isEmpty(Name))
        {
            this.setNotification("warning", "¡No hay nombre!", "Ingrese un nombre por favor...");
        }
        else if (Security.isEmpty(LastName))
        {
            this.setNotification("warning", "¡No hay apellido!", "Ingrese un apellido por favor...");
        }
        else if (Security.isEmpty(Email))
        {
            this.setNotification("warning", "¡No hay email!", "Ingrese un email por favor...");
        }
        else if (!Security.isEmail(Email))
        {
            this.setNotification("warning", "¡Email inválido!", "El email ingresado no es válido...");
        }
        else if (Security.isEmpty(RFC))
        {
            this.setNotification("warning", "¡No hay rfc!", "Ingrese un rfc por favor...");
        }
        else if (!Security.isRFC(RFC))
        {
            this.setNotification("warning", "¡RFC Inválido!", "El RFC ingresado no es válido...");
        }
        else if (listOfValidAddresses.Count == 0)
        {
            this.setNotification("warning", "¡No hay dirección!", "Ingresa una dirección como mínimo por favor...");
        }
        else if (flag)
        {
            Customers customer = new Customers(idCustomer, Name, LastName, Email, RFC, listOfValidAddresses);

            int result = customer.saveCustomer();

            switch (result)
            {
                case 1:
                    Response.Redirect(webURL + "views/customers/editcustomer.aspx?id=" + idCustomer + "&action=notify&nid=" + 1, false);
                    break;
                case -3:
//.........这里部分代码省略.........
开发者ID:efigarolam,项目名称:Snackthat,代码行数:101,代码来源:editcustomer.aspx.cs


注:本文中的Customers.saveCustomer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。