Exemple #1
0
        public Int64 Insert(customerRegistration objcustomerRegistration)
        {
            Int64 result = 0;

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "customer_Insert";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;

                SqlParameter param = new SqlParameter();
                param.ParameterName = "@id";
                param.Value         = 0;
                param.SqlDbType     = SqlDbType.BigInt;
                param.Direction     = ParameterDirection.InputOutput;
                cmd.Parameters.Add(param);
                cmd.Parameters.AddWithValue("@customerName", objcustomerRegistration.customerName);
                cmd.Parameters.AddWithValue("@email", objcustomerRegistration.email);
                cmd.Parameters.AddWithValue("@phoneNo", objcustomerRegistration.phoneNo);
                cmd.Parameters.AddWithValue("@address", objcustomerRegistration.address);
                cmd.Parameters.AddWithValue("@password", objcustomerRegistration.password);

                cmd.Parameters.AddWithValue("@latitude", objcustomerRegistration.latitude);
                cmd.Parameters.AddWithValue("@lognitude", objcustomerRegistration.lognitude);
                cmd.Parameters.AddWithValue("@img", objcustomerRegistration.img);


                cmd.Parameters.AddWithValue("@annivarsaryDate", objcustomerRegistration.annivarsaryDate);
                cmd.Parameters.AddWithValue("@birthdate", objcustomerRegistration.birthdate);
                cmd.Parameters.AddWithValue("@business", objcustomerRegistration.business);
                cmd.Parameters.AddWithValue("@job", objcustomerRegistration.job);
                cmd.Parameters.AddWithValue("@reference", objcustomerRegistration.reference);

                cmd.Parameters.AddWithValue("@days", objcustomerRegistration.days);
                cmd.Parameters.AddWithValue("@deliveryShift", objcustomerRegistration.deliveryShift);
                cmd.Parameters.AddWithValue("@deliveryTime", objcustomerRegistration.deliveryTime);
                cmd.Parameters.AddWithValue("@doorStep", objcustomerRegistration.doorStep);



                ConnectionString.Open();
                cmd.ExecuteNonQuery();
                result = Convert.ToInt64(param.Value);
            }
            catch (Exception ex)
            {
                ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(result);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(result);
        }
Exemple #2
0
        public customerRegistration  SelectById(Int64 id)
        {
            SqlDataAdapter       da;
            DataSet              ds = new DataSet();
            customerRegistration objcustomerRegistration = new customerRegistration();

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "customer__SelectById";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;
                cmd.Parameters.AddWithValue("@id", id);
                ConnectionString.Open();
                da = new SqlDataAdapter(cmd);
                da.Fill(ds);
                //vid, vendorName, Address1, Address2, MobileNo1, MobileNo2, email, landline, fk_countryId, fk_stateId, fk_cityId, createddate, isdelete, isactive

                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0] != null)
                        {
                            if (ds.Tables[0].Rows.Count > 0)
                            {
                                objcustomerRegistration.id              = Convert.ToInt64(ds.Tables[0].Rows[0]["id"]);
                                objcustomerRegistration.customerName    = Convert.ToString(ds.Tables[0].Rows[0]["customerName"]);
                                objcustomerRegistration.email           = Convert.ToString(ds.Tables[0].Rows[0]["email"]);
                                objcustomerRegistration.phoneNo         = Convert.ToString(ds.Tables[0].Rows[0]["phoneNo"]);
                                objcustomerRegistration.address         = Convert.ToString(ds.Tables[0].Rows[0]["address"]);
                                objcustomerRegistration.password        = Convert.ToString(ds.Tables[0].Rows[0]["password"]);
                                objcustomerRegistration.email           = Convert.ToString(ds.Tables[0].Rows[0]["email"]);
                                objcustomerRegistration.latitude        = Convert.ToString(ds.Tables[0].Rows[0]["latitude"]);
                                objcustomerRegistration.lognitude       = Convert.ToString(ds.Tables[0].Rows[0]["lognitude"]);
                                objcustomerRegistration.img             = Convert.ToString(ds.Tables[0].Rows[0]["img"]);
                                objcustomerRegistration.annivarsaryDate = Convert.ToDateTime(ds.Tables[0].Rows[0]["annivarsaryDate"]);
                                objcustomerRegistration.birthdate       = Convert.ToDateTime(ds.Tables[0].Rows[0]["birthdate"]);
                                objcustomerRegistration.business        = Convert.ToString(ds.Tables[0].Rows[0]["business"]);
                                objcustomerRegistration.job             = Convert.ToString(ds.Tables[0].Rows[0]["job"]);
                                objcustomerRegistration.reference       = Convert.ToString(ds.Tables[0].Rows[0]["reference"]);
                                objcustomerRegistration.days            = Convert.ToString(ds.Tables[0].Rows[0]["days"]);
                                objcustomerRegistration.deliveryShift   = Convert.ToString(ds.Tables[0].Rows[0]["deliveryShift"]);
                                objcustomerRegistration.deliveryTime    = Convert.ToString(ds.Tables[0].Rows[0]["deliveryTime"]);
                                objcustomerRegistration.doorStep        = Convert.ToString(ds.Tables[0].Rows[0]["doorStep"]);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(null);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(objcustomerRegistration);
        }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Int64 Result = 0;
        customerRegistration objcustomerRegistration = new customerRegistration();


        //     id, customerName, email, phoneNo, address, isdelete, isactive, password, latitude, lognitude, img,
        //annivarsaryDate,
        //birthdate, business, job, reference, days, deliveryShift, deliveryTime, doorStep
        objcustomerRegistration.customerName    = txtName.Text.Trim();
        objcustomerRegistration.email           = txtAddress1.Text.Trim();
        objcustomerRegistration.phoneNo         = txtPhoneno.Text.Trim();
        objcustomerRegistration.address         = txtAddress1.Text.Trim();
        objcustomerRegistration.password        = txtpassword.Text.Trim();
        objcustomerRegistration.latitude        = "";
        objcustomerRegistration.lognitude       = "";
        objcustomerRegistration.annivarsaryDate = Convert.ToDateTime(txtAnnivarsaryDate.Text.Trim());
        objcustomerRegistration.birthdate       = Convert.ToDateTime(txtBirthdate.Text.Trim());
        objcustomerRegistration.business        = txtBusiness.Text.Trim();
        objcustomerRegistration.job             = txtJob.Text.Trim();
        objcustomerRegistration.reference       = txtReference.Text.Trim();

        if (ViewState["fileName"] != null)
        {
            objcustomerRegistration.img = ViewState["fileName"].ToString();
        }
        string days = "", deliveryShift = "", deliveryTime = "", doorStep = "";

        if (rdoDays_daily.Checked == true)
        {
            days = rdoDays_daily.Text.Trim();
        }
        else if (rdoDays_daily.Checked == true)
        {
            days = rdoDays_daily.Text.Trim();
        }
        //----
        if (rdoShift_morning.Checked == true)
        {
            deliveryShift = rdoShift_morning.Text.Trim();
        }
        else if (rdoShift_evening.Checked == true)
        {
            deliveryShift = rdoShift_evening.Text.Trim();
        }
        //----
        if (rdoDayTime_6To8.Checked == true)
        {
            deliveryTime = rdoDayTime_6To8.Text.Trim();
        }
        else if (rdoDayTime_after8.Checked == true)
        {
            deliveryTime = rdoDayTime_after8.Text.Trim();
        }
        //----
        if (rdodoorstepDelivery_doorbell.Checked == true)
        {
            doorStep = rdodoorstepDelivery_doorbell.Text.Trim();
        }
        else if (rdodoorstepDelivery_withoutDoorbell.Checked == true)
        {
            doorStep = rdodoorstepDelivery_withoutDoorbell.Text.Trim();
        }
        objcustomerRegistration.days          = days.Trim();
        objcustomerRegistration.deliveryShift = deliveryShift.Trim();
        objcustomerRegistration.deliveryTime  = deliveryTime.Trim();
        objcustomerRegistration.doorStep      = doorStep.Trim();

        if (Request.QueryString["id"] != null)
        {
            objcustomerRegistration.id = Convert.ToInt32(ocommon.Decrypt(Request.QueryString["id"].ToString(), true));
            bool res = CheckMobileNumberExitOrNot(objcustomerRegistration.phoneNo, "u", objcustomerRegistration.id.ToString());
            if (res == true)
            {
                spnMessgae.Style.Add("color", "red");
                spnMessgae.InnerText = "Duplicate Mobile No";
            }
            else
            {
                Result = (new Cls_customerRegistration_b().Update(objcustomerRegistration));

                if (Result > 0)
                {
                    try
                    {
                        DataTable ds = new DataTable();
                        ds = (DataTable)ViewState["dtprod"];

                        ConnectionString.Close();
                        ConnectionString.Open();
                        foreach (RepeaterItem item in repProduct.Items)
                        {
                            Label      fk_productId = (Label)item.FindControl("lblProductId");
                            TextBox    qty          = (TextBox)item.FindControl("lblQty");
                            SqlCommand cmd          = new SqlCommand();
                            cmd.CommandText = "Customer_ProductUpdate";
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Connection  = ConnectionString;

                            SqlParameter param = new SqlParameter();
                            param.ParameterName = "@id";
                            param.Value         = 0;
                            param.SqlDbType     = SqlDbType.Int;
                            param.Direction     = ParameterDirection.InputOutput;
                            cmd.Parameters.Add(param);
                            cmd.Parameters.AddWithValue("@fk_productId", Convert.ToInt64(fk_productId.Text));
                            cmd.Parameters.AddWithValue("@Fk_customerId", Result);
                            cmd.Parameters.AddWithValue("@qty", qty.Text);
                            Int64 result = cmd.ExecuteNonQuery();
                        }
                    }
                    catch (Exception p)
                    { }
                    finally { ConnectionString.Close(); }
                    Clear();
                    Response.Redirect(Page.ResolveUrl("~/manageCustomerRegistration.aspx? mode=u"));
                }
                else
                {
                    Clear();
                    spnMessgae.Style.Add("color", "red");
                    spnMessgae.InnerText = "Customer Not Updated";
                    BindCustomer(Convert.ToInt64(ocommon.Decrypt(Request.QueryString["id"].ToString(), true)));
                }
            }
        }
        else
        {
            bool res = CheckMobileNumberExitOrNot(objcustomerRegistration.phoneNo, "i", "0");
            if (res == true)
            {
                spnMessgae.Style.Add("color", "red");
                spnMessgae.InnerText = "Duplicate Mobile No";
            }
            else
            {
                Result = (new Cls_customerRegistration_b().Insert(objcustomerRegistration));

                if (Result > 0)
                {
                    try
                    {
                        DataTable ds = new DataTable();
                        ds = (DataTable)ViewState["dtprod"];

                        ConnectionString.Close();
                        ConnectionString.Open();
                        foreach (RepeaterItem item in repProduct.Items)
                        {
                            Label      fk_productId = (Label)item.FindControl("lblProductId");
                            TextBox    qty          = (TextBox)item.FindControl("lblQty");
                            SqlCommand cmd          = new SqlCommand();
                            cmd.CommandText = "Customer_ProductUpdate";
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Connection  = ConnectionString;

                            SqlParameter param = new SqlParameter();
                            param.ParameterName = "@id";
                            param.Value         = 0;
                            param.SqlDbType     = SqlDbType.Int;
                            param.Direction     = ParameterDirection.InputOutput;
                            cmd.Parameters.Add(param);
                            cmd.Parameters.AddWithValue("@fk_productId", Convert.ToInt64(fk_productId.Text));
                            cmd.Parameters.AddWithValue("@Fk_customerId", Result);
                            cmd.Parameters.AddWithValue("@qty", qty.Text);
                            Int64 result = cmd.ExecuteNonQuery();
                        }
                    }
                    catch (Exception p)
                    { }
                    finally { ConnectionString.Close(); }

                    Clear();
                    Response.Redirect(Page.ResolveUrl("~/manageCustomerRegistration.aspx? mode=i"));
                }
                else
                {
                    Clear();
                    spnMessgae.Style.Add("color", "red");
                    spnMessgae.InnerText = "Customer Boy Not Inserted";
                }
            }
        }
    }
Exemple #4
0
    public void customerRegistration(string OrderProducts_JSONString, string customerName, string email, string phoneNo, string address, string password, string latitude, string lognitude, string annivarsaryDate, string birthdate, string business, string job, string reference, string img, string imgextension, string days, string deliveryShift, string deliveryTime, string doorStep)
    {
        string finalResult = string.Empty;

        //Customer_orders objorders = new Customer_orders();
        customerRegistration objcustomerRegistration = new customerRegistration();

        objcustomerRegistration.customerName = customerName.ToString();
        objcustomerRegistration.email        = email.Trim();
        objcustomerRegistration.phoneNo      = phoneNo.Trim();
        objcustomerRegistration.address      = address.Trim();
        objcustomerRegistration.password     = password.Trim();
        objcustomerRegistration.latitude     = latitude.ToString();
        objcustomerRegistration.lognitude    = lognitude.ToString();

        if (annivarsaryDate == string.Empty)
        {
            //objcustomerRegistration.annivarsaryDate = Convert.ToDateTime(annivarsaryDate);
        }
        else
        {
            objcustomerRegistration.annivarsaryDate = Convert.ToDateTime(annivarsaryDate);
        }

        //  objcustomerRegistration.annivarsaryDate = Convert.ToDateTime(annivarsaryDate);

        if (birthdate == string.Empty)
        {
        }
        else
        {
            objcustomerRegistration.birthdate = Convert.ToDateTime(birthdate);
        }

        // objcustomerRegistration.birthdate = Convert.ToDateTime(birthdate );
        objcustomerRegistration.business  = business.Trim();
        objcustomerRegistration.job       = job.Trim();
        objcustomerRegistration.reference = reference.Trim();

        if (!string.IsNullOrEmpty(img))
        {
            objcustomerRegistration.img = customerProfileImage(img, imgextension);
        }

        objcustomerRegistration.days          = days.Trim();
        objcustomerRegistration.deliveryShift = deliveryShift.Trim();
        objcustomerRegistration.deliveryTime  = deliveryTime.Trim();
        objcustomerRegistration.doorStep      = doorStep.Trim();
        //[{"fk_productId":"1","qty":"1"}    ,{"fk_productId":"2","qty":"2"}]
        Int64 OrderProductAdd = 0;
        Int64 OrderId         = 0;
        var   dtOrderProducts = JsonConvert.DeserializeObject <DataTable>(OrderProducts_JSONString);

        if (dtOrderProducts != null)
        {
            if (dtOrderProducts.Rows.Count > 0)
            {
                //OrderId = (new Cls_Customer_order_b().Insert(objorders));
                // OrderId = (new Cls_orders_b().Insert(objorders));
                bool res = CheckMobileNumberExitOrNot(objcustomerRegistration.phoneNo, "i", "0");
                if (res == true)
                {
                    finalResult = "{\"success\" : 0, \"message\" : \"Duplicate Mobile No\", \"data\" : \"\"}";
                }
                else
                {
                    OrderId = (new Cls_customerRegistration_b().Insert(objcustomerRegistration));

                    if (OrderId > 0)
                    {
                        try
                        {
                            ConnectionString.Close();
                            ConnectionString.Open();
                            // dtOrderProducts
                            for (int i = 0; i < dtOrderProducts.Rows.Count; i++)
                            {
                                //Label fk_productId = (Label)item.FindControl("lblProductId");
                                //TextBox qty = (TextBox)item.FindControl("lblQty");
                                SqlCommand cmd = new SqlCommand();
                                cmd.CommandText = "Customer_ProductUpdate";
                                cmd.CommandType = CommandType.StoredProcedure;
                                cmd.Connection  = ConnectionString;

                                SqlParameter param = new SqlParameter();
                                param.ParameterName = "@id";
                                param.Value         = 0;
                                param.SqlDbType     = SqlDbType.Int;
                                param.Direction     = ParameterDirection.InputOutput;
                                cmd.Parameters.Add(param);
                                cmd.Parameters.AddWithValue("@fk_productId", Convert.ToInt64(dtOrderProducts.Rows[i]["fk_productId"].ToString()));
                                cmd.Parameters.AddWithValue("@Fk_customerId", OrderId);
                                cmd.Parameters.AddWithValue("@qty", Convert.ToInt64(dtOrderProducts.Rows[i]["qty"].ToString()));
                                Int64 result = cmd.ExecuteNonQuery();
                            }
                        }
                        catch (Exception p)
                        { }
                        finally { ConnectionString.Close(); }


                        finalResult = "{\"success\" : 1, \"message\" : \"Record Saved Sucessfully\", \"data\" : \"\"}";
                    }
                    else
                    {
                        finalResult = "{\"success\" :0, \"message\" : \"Record Not Saved\", \"data\" : \"\"}";
                    }
                }
            }
        }

        if ((OrderId > 0))
        {
            //SendOrderMail(OrderId);
            finalResult = "{\"success\" : 1, \"message\" : \"Record Saved Sucessfully\", \"data\" : \"\"}";
        }
        else
        {
            finalResult = "{\"success\" : 0, \"message\" : \"Record Not Saved\", \"data\" : \"\"}";
        }
        Context.Response.Clear();
        Context.Response.ContentType = "application/json";
        Context.Response.Flush();
        Context.Response.Write(finalResult);
        Context.Response.End();
    }
    public void BindCustomer(Int64 BankId)
    {
        customerRegistration objcustomerRegistration = (new Cls_customerRegistration_b().SelectById(BankId));

        if (objcustomerRegistration != null)
        {
            txtName.Text            = objcustomerRegistration.customerName;
            txtEmail.Text           = objcustomerRegistration.email;
            txtPhoneno.Text         = objcustomerRegistration.phoneNo;
            txtAddress1.Text        = objcustomerRegistration.phoneNo;
            txtpassword.Text        = objcustomerRegistration.password;
            txtAnnivarsaryDate.Text = objcustomerRegistration.annivarsaryDate.ToString();
            txtBirthdate.Text       = objcustomerRegistration.birthdate.ToString();
            txtBusiness.Text        = objcustomerRegistration.business;
            txtJob.Text             = objcustomerRegistration.job;
            txtReference.Text       = objcustomerRegistration.reference;

            string days = "", deliveryShift = "", deliveryTime = "", doorStep = "";


            if (objcustomerRegistration.days == "Daily")
            {
                rdoDays_daily.Checked        = true;
                rdoDays_alternetdays.Checked = false;
            }
            else if (objcustomerRegistration.days == "Alternet Days")
            {
                rdoDays_daily.Checked        = false;
                rdoDays_alternetdays.Checked = true;
            }
            //----
            if (objcustomerRegistration.deliveryShift == "Morning")
            {
                rdoShift_morning.Checked = true;
                rdoShift_evening.Checked = false;
            }
            else if (objcustomerRegistration.deliveryShift == "Evening")
            {
                rdoShift_morning.Checked = false;
                rdoShift_evening.Checked = true;
            }
            //----
            if (objcustomerRegistration.deliveryTime == "6am To 8 am")
            {
                rdoDayTime_6To8.Checked = true;
                rdodoorstepDelivery_doorbell.Checked = false;
                //deliveryTime = rdoDayTime_6To8.Text.Trim();
            }
            else if (objcustomerRegistration.deliveryTime == "After 8am")
            {
                rdoDayTime_6To8.Checked = false;
                rdodoorstepDelivery_doorbell.Checked = true;
            }
            //----
            if (objcustomerRegistration.doorStep == "Doorbell")
            {
                rdodoorstepDelivery_doorbell.Checked        = true;
                rdodoorstepDelivery_withoutDoorbell.Checked = false;
            }
            else if (objcustomerRegistration.doorStep == "Without Doorbell")
            {
                rdodoorstepDelivery_doorbell.Checked        = false;
                rdodoorstepDelivery_withoutDoorbell.Checked = true;
            }


            if (!string.IsNullOrEmpty(objcustomerRegistration.img))
            {
                imgCategory.Visible    = true;
                ViewState["fileName"]  = objcustomerRegistration.img;
                imgCategory.ImageUrl   = categoryMainPath + objcustomerRegistration.img;
                btnImageUpload.Visible = false;
                btnRemove.Visible      = true;
            }
            else
            {
                btnImageUpload.Visible = true;
            }


            try
            {
                ConnectionString.Open();
                ConnectionString.Close();
            }
            catch { }
            finally { ConnectionString.Close(); }
        }
        BindProductGrid(BankId);
    }