Esempio n. 1
0
        public void cargarBarrio()
        {
            ASPxPageControl tabs = (ASPxPageControl)ASPxGridView1.FindEditFormTemplateControl("pageControl");
            ASPxFormLayout  form = (ASPxFormLayout)tabs.FindControl("formLayoutUbicacion");
            /* PROVINCIA */
            ASPxComboBox comboProvincia = (ASPxComboBox)form.FindControl("cmbProvincia");
            /* CANTON */
            ASPxComboBox comboCanton = (ASPxComboBox)form.FindControl("cmbCanton");
            /* DISTRITO */
            ASPxComboBox comboDistrito = (ASPxComboBox)form.FindControl("cmbDistrito");
            /* BARRIO */
            ASPxComboBox comboBarrio = (ASPxComboBox)form.FindControl("cmbBarrio");

            comboBarrio.Items.Clear();
            if (comboProvincia.Value != null && comboCanton.Value != null && comboDistrito.Value != null)
            {
                using (var conexion = new DataModelFE())
                {
                    foreach (var item in conexion.Ubicacion.
                             Where(x => x.codProvincia == comboProvincia.Value.ToString()).
                             Where(x => x.codCanton == comboCanton.Value.ToString()).
                             Where(x => x.codDistrito == comboDistrito.Value.ToString()).
                             Select(x => new { x.codBarrio, x.nombreBarrio }).Distinct())
                    {
                        comboBarrio.Items.Add(item.nombreBarrio, item.codBarrio);
                    }
                    comboBarrio.IncrementalFilteringMode = IncrementalFilteringMode.Contains;
                    comboBarrio.SelectedIndex            = 0;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            gridview_tangpham.DataSource =
                new[] {
                new { stt       = "01", MaQuaTang = "N/A", TenQuaTang = "Phiếu Giảm Giá", DonViTinh = "N/A", PhanLoai = "Tặng phẩm", GiaTri = "15.000",
                      lotid     = "SL0001", duedate = "01/01/2015", SoLuong = "2",
                      ThanhTien = "0", MoTa = "NAAN Solution" },
                new { stt       = "02", MaQuaTang = "N/A", TenQuaTang = "Gốm Minh Long", DonViTinh = "N/A", PhanLoai = "Tặng phẩm", GiaTri = "15.000",
                      lotid     = "SL0001", duedate = "01/01/2015", SoLuong = "3",
                      ThanhTien = "0", MoTa = "NAAN Solution" },
                new { stt       = "03", MaQuaTang = "SP00001", TenQuaTang = "Hàng hóa 1", DonViTinh = "Hộp", PhanLoai = "Hàng hóa", GiaTri = "15.000",
                      lotid     = "SL0001", duedate = "01/01/2015", SoLuong = "1",
                      ThanhTien = "0", MoTa = "" },
                new { stt       = "04", MaQuaTang = "SP00002", TenQuaTang = "Hàng hóa 2", DonViTinh = "Hộp", PhanLoai = "Hàng hóa", GiaTri = "15.000",
                      lotid     = "SL0001", duedate = "01/01/2015", SoLuong = "1",
                      ThanhTien = "0", MoTa = "" },
                new { stt       = "05", MaQuaTang = "SP00003", TenQuaTang = "Hàng hóa 3", DonViTinh = "Thùng", PhanLoai = "Hàng hóa", GiaTri = "15.000",
                      lotid     = "SL0001", duedate = "01/01/2015", SoLuong = "1",
                      ThanhTien = "0", MoTa = "" },
            };
            gridview_tangpham.DataBind();

            /* Setting for tab 1 */
            ASPxFormLayout form_infoquyenloi    = navbar_info.Groups[1].FindControl("form_infoquyenloi") as ASPxFormLayout;
            ASPxGridView   gridview_hanghoatang = form_infoquyenloi.FindControl("gridview_hanghoatang") as ASPxGridView;

            gridview_hanghoatang.DataSource = new[] {
                new{ productid = "SP00001", productname = "Hàng hóa 1", productunitid = "Hộp", lotid = "L00001",
                     duedate   = "01/01/2015", condition_buy = "5", condition_give = "1" },
                new{ productid = "SP00002", productname = "Hàng hóa 2", productunitid = "Hộp", lotid = "L00002",
                     duedate   = "01/01/2015", condition_buy = "10", condition_give = "1" },
                new{ productid = "SP00003", productname = "Hàng hóa 3", productunitid = "Thùng", lotid = "L00003",
                     duedate   = "01/01/2015", condition_buy = "100", condition_give = "1" },
            };
            gridview_hanghoatang.DataBind();
            gridview_hanghoatang.Visible = true;
            ASPxLabel lbl_title_khuyenmai2 = form_infoquyenloi.FindControl("lbl_title_khuyenmai2") as ASPxLabel;

            lbl_title_khuyenmai2.Visible = true;

            ASPxGridView gridview_hanghoabonus = form_infoquyenloi.FindControl("gridview_hanghoabonus") as ASPxGridView;

            gridview_hanghoabonus.DataSource =
                new[] {
                new { TenQuaTang = "Phiếu Giảm Giá", GiaTri = "15.000", SoLuong = "2", ThanhTien = "30.000", MoTa = "NAAN Solution" },
                new { TenQuaTang = "Gấu Bông", GiaTri = "15.000", SoLuong = "3", ThanhTien = "45.000", MoTa = "NAAN Solution" },
            };
            gridview_hanghoabonus.DataBind();
            gridview_hanghoabonus.Visible = false;

            ASPxLabel      lbl_title_khuyenmai3 = form_infoquyenloi.FindControl("lbl_title_khuyenmai3") as ASPxLabel;
            ASPxRoundPanel round_chietkhau      = form_infoquyenloi.FindControl("round_chietkhau") as ASPxRoundPanel;

            round_chietkhau.Visible      = false;
            lbl_title_khuyenmai3.Visible = false;
        }
        protected void grd_DSRole_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e)
        {
            Utils.notifierListClearGrid(grd_DSRole, Constant.NOTIFY_CLEAR);
            List <Error_Obj> lstError  = new List <Error_Obj>();
            ASPxFormLayout   pnLayData = grd_DSRole.FindEditFormTemplateControl("LayOutThemSua") as ASPxFormLayout;
            ASPxTextBox      txtName   = pnLayData.FindControl("txtName") as ASPxTextBox;

            if (String.IsNullOrEmpty(txtName.Text))
            {
                lstError.Add(new Error_Obj {
                    error = "[Tên role] không được để trống."
                });
            }
            Role role = ctlRole.getRolesByName(txtName.Text.Trim());

            if (role != null && grd_DSRole.IsNewRowEditing)
            {
                lstError.Add(new Error_Obj {
                    error = "[Tên role] đã tồn tại."
                });
            }
            if (lstError.Count > 0)
            {
                e.Errors[grd_DSRole.Columns[0]] = "error";
                Utils.notifierListErrorGrid(grd_DSRole, Constant.NOTIFY_FAILURE, lstError);
            }
        }
 protected void grd_DSRole_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
 {
     try
     {
         e.Cancel = true;
         ASPxFormLayout pnLayData = grd_DSRole.FindEditFormTemplateControl("LayOutThemSua") as ASPxFormLayout;
         ASPxMemo       txtNote   = pnLayData.FindControl("txtNote") as ASPxMemo;
         ASPxTextBox    txtName   = pnLayData.FindControl("txtName") as ASPxTextBox;
         ctlRole.insertRoles(txtName.Text, txtNote.Text);
         BindataThemNhanh();
         Utils.notifierGrid(grd_DSRole, Constant.NOTIFY_SUCCESS, "Bạn đã thêm thành công Role có [" + txtName.Text + "]");
     }
     catch (Exception ex)
     {
         Utils.notifierGrid(grd_DSRole, Constant.NOTIFY_FAILURE, ex.Message + " " + ex.StackTrace);
     }
 }
 protected void grd_DSRole_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
 {
     try
     {
         e.Cancel = true;
         Int32          idRoles   = Convert.ToInt32(e.Keys[grd_DSRole.KeyFieldName]);
         ASPxFormLayout pnLayData = grd_DSRole.FindEditFormTemplateControl("LayOutThemSua") as ASPxFormLayout;
         ASPxMemo       txtNote   = pnLayData.FindControl("txtNote") as ASPxMemo;
         ASPxTextBox    txtName   = pnLayData.FindControl("txtName") as ASPxTextBox;
         ctlRole.updateRoles(idRoles, txtName.Text, txtNote.Text);
         BindataThemNhanh();
         Utils.notifierGrid(grd_DSRole, Constant.NOTIFY_SUCCESS, "Bạn đã cập nhập thành công cho Role có ID [" + idRoles.ToString() + "]");
     }
     catch (Exception ex)
     {
         Utils.notifierGrid(grd_DSRole, Constant.NOTIFY_FAILURE, ex.Message + " " + ex.StackTrace);
     }
 }
        protected void grd_DSUsers_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e)
        {
            Utils.notifierListClearGrid(grd_DSUsers, Constant.NOTIFY_CLEAR);
            List <Error_Obj> lstError           = new List <Error_Obj>();
            ASPxFormLayout   LayOutThemSua      = grd_DSUsers.FindEditFormTemplateControl("LayOutThemSua") as ASPxFormLayout;
            ASPxTextBox      txtId_Login        = LayOutThemSua.FindControl("Id_Login") as ASPxTextBox;
            ASPxTextBox      txtPassword        = LayOutThemSua.FindControl("Password") as ASPxTextBox;
            ASPxTextBox      txtPasswordConfirm = LayOutThemSua.FindControl("PasswordConfirm") as ASPxTextBox;

            if (String.IsNullOrEmpty(txtId_Login.Text))
            {
                lstError.Add(new Error_Obj {
                    error = "[Tên đăng nhập] không được để trống."
                });
            }

            User user = ctlUser.getUsersByIDLogin(txtId_Login.Text.Trim());

            if (user != null && grd_DSUsers.IsNewRowEditing)
            {
                lstError.Add(new Error_Obj {
                    error = "Tên đăng nhập đã tồn tại."
                });
            }
            if (String.IsNullOrEmpty(txtPassword.Text) && grd_DSUsers.IsNewRowEditing)
            {
                lstError.Add(new Error_Obj {
                    error = "[Mật khẩu] không được để trống."
                });
            }
            if (!txtPassword.Text.Equals(txtPasswordConfirm.Text))
            {
                lstError.Add(new Error_Obj {
                    error = "[Xác nhận mật khẩu] không chính xác."
                });
            }
            if (lstError.Count > 0)
            {
                e.Errors[grd_DSUsers.Columns[0]] = "error";
                Utils.notifierListErrorGrid(grd_DSUsers, Constant.NOTIFY_FAILURE, lstError);
            }
        }
Esempio n. 7
0
        protected void ASPxGridView1_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e)
        {
            ASPxPageControl tabs = (ASPxPageControl)ASPxGridView1.FindEditFormTemplateControl("pageControl");

            if (tabs != null)
            {
                ASPxFormLayout form = (ASPxFormLayout)tabs.FindControl("formLayoutUbicacion");
                /* PROVINCIA */
                ASPxComboBox comboProvincia = (ASPxComboBox)form.FindControl("cmbProvincia");
                /* CANTON */
                ASPxComboBox comboCanton = (ASPxComboBox)form.FindControl("cmbCanton");
                /* DISTRITO */
                ASPxComboBox comboDistrito = (ASPxComboBox)form.FindControl("cmbDistrito");
                /* BARRIO */
                ASPxComboBox comboBarrio = (ASPxComboBox)form.FindControl("cmbBarrio");
                ASPxMemo     otraSena    = (ASPxMemo)form.FindControl("txtOtraSenas");

                if (comboProvincia.Value == null || comboCanton.Value == null || comboDistrito.Value == null || comboBarrio.Value == null || string.IsNullOrWhiteSpace(otraSena.Text))
                {
                    e.RowError = "La ubicación es obligatoria (provincia, cantón, distrito, barrio y otras señas";
                }

                if (e.NewValues["correoElectronico"] != null)
                {
                    Regex    validator = new Regex(@"\s*\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*\s*");
                    string[] correos   = e.NewValues["correoElectronico"].ToString().Split(',');
                    foreach (var correo in correos)
                    {
                        if (!validator.IsMatch(correo))
                        {
                            AddError(e.Errors, this.ASPxGridView1.Columns["correoElectronico"], string.Format("Verificar formato: {0}", correo));
                        }
                    }

                    if (correos.Length > 5)
                    {
                        e.RowError = "Solo puede agregar un máximo de 5 correos";
                    }
                }
            }
        }
Esempio n. 8
0
        private void cargaPlanes()
        {
            /* PLAN */

            ASPxPageControl tabs = (ASPxPageControl)ASPxGridView1.FindEditFormTemplateControl("pageControl");
            ASPxFormLayout  form = (ASPxFormLayout)tabs.FindControl("formLayoutUbicacion");

            ASPxComboBox comboPlan = (ASPxComboBox)form.FindControl("cmbPlan");

            comboPlan.Items.Clear();
            using (var conexion = new DataModelFE())
            {
                foreach (var item in conexion.TipoPlan.Where(x => x.estado == Estado.ACTIVO.ToString()).ToList())
                {
                    comboPlan.Items.Add(item.descripcion, item.codigo);
                }
            }
        }
Esempio n. 9
0
        public void cargarProvincias()
        {
            ASPxPageControl tabs = (ASPxPageControl)ASPxGridView1.FindEditFormTemplateControl("pageControl");
            ASPxFormLayout  form = (ASPxFormLayout)tabs.FindControl("formLayoutUbicacion");

            /* PROVINCIA */
            ASPxComboBox comboProvincia = (ASPxComboBox)form.FindControl("cmbProvincia");

            comboProvincia.Items.Clear();

            using (var conexion = new DataModelFE())
            {
                foreach (var item in conexion.Ubicacion.
                         Select(x => new { x.codProvincia, x.nombreProvincia }).Distinct())
                {
                    comboProvincia.Items.Add(item.nombreProvincia, item.codProvincia);
                }
                comboProvincia.IncrementalFilteringMode = IncrementalFilteringMode.Contains;
            }
        }
Esempio n. 10
0
        public static T setView2ObjectLayout <T>(T obj, ASPxFormLayout layout)
        {
            Type type = obj.GetType();

            foreach (var item in type.GetProperties())
            {
                var control = layout.FindControl(item.Name);
                if (control == null)
                {
                    continue;
                }
                Type type1 = control.GetType();
                if (type1 == typeof(ASPxTextBox))
                {
                    item.SetValue(obj, (control as ASPxTextBox).Text);
                }
            }


            return(obj);
        }
Esempio n. 11
0
    protected void ASPxFormLayout1_E8_SelectedIndexChanged(object sender, EventArgs e)
    {
        NpgsqlConnection myConn1 = new NpgsqlConnection(connString);

        ASPxFormLayout fl_1 = (ASPxFormLayout)ASPxNavBar1.Groups[1].FindControl("ASPxFormLayout1");

        ASPxComboBox combox_sdz = (ASPxComboBox)fl_1.FindControl("ASPxFormLayout1_E8");
        ASPxTextBox  max_pot    = (ASPxTextBox)fl_1.FindControl("ASPxFormLayout1_E3");
        ASPxTextBox  min_pot    = (ASPxTextBox)fl_1.FindControl("ASPxFormLayout1_E1");
        ASPxTextBox  avg_pot    = (ASPxTextBox)fl_1.FindControl("ASPxFormLayout1_E2");

        ASPxTextBox max_pot_rz = (ASPxTextBox)fl_1.FindControl("ASPxFormLayout1_E6");
        ASPxTextBox min_pot_rz = (ASPxTextBox)fl_1.FindControl("ASPxFormLayout1_E4");
        ASPxTextBox avg_pot_rz = (ASPxTextBox)fl_1.FindControl("ASPxFormLayout1_E5");

        try
        {
            NpgsqlCommand cmd_get_subjectdata_max = new NpgsqlCommand(String.Format("select s.subject_name as subject, max(m.pot_tz) as sum from \"Monitoring_SDZ\" as m LEFT JOIN \"Subject\" as s on m.subject_id=s.subject_id where s.subject_name = '{0}' GROUP BY subject", combox_sdz.SelectedItem.ToString()), myConn1);
            myConn1.Open();

            NpgsqlDataReader dataReaderGetSubject = cmd_get_subjectdata_max.ExecuteReader();

            while (dataReaderGetSubject.Read())
            {
                max_pot.Text = dataReaderGetSubject.GetValue(dataReaderGetSubject.GetOrdinal("sum")).ToString();
            }

            myConn1.Close();

            NpgsqlCommand cmd_get_subjectdata_min = new NpgsqlCommand(String.Format("select s.subject_name as subject, min(m.pot_tz) as sum from \"Monitoring_SDZ\" as m LEFT JOIN \"Subject\" as s on m.subject_id=s.subject_id where s.subject_name = '{0}' GROUP BY subject", combox_sdz.SelectedItem.ToString()), myConn1);
            myConn1.Open();

            NpgsqlDataReader dataReaderGetSubject2 = cmd_get_subjectdata_min.ExecuteReader();

            while (dataReaderGetSubject2.Read())
            {
                min_pot.Text = dataReaderGetSubject2.GetValue(dataReaderGetSubject2.GetOrdinal("sum")).ToString();
            }

            myConn1.Close();

            NpgsqlCommand cmd_get_subjectdata_avg = new NpgsqlCommand(String.Format("select s.subject_name as subject, avg(m.pot_tz) as sum from \"Monitoring_SDZ\" as m LEFT JOIN \"Subject\" as s on m.subject_id=s.subject_id where s.subject_name = '{0}' GROUP BY subject", combox_sdz.SelectedItem.ToString()), myConn1);
            myConn1.Open();

            NpgsqlDataReader dataReaderGetSubject3 = cmd_get_subjectdata_avg.ExecuteReader();

            while (dataReaderGetSubject3.Read())
            {
                avg_pot.Text = dataReaderGetSubject3.GetValue(dataReaderGetSubject3.GetOrdinal("sum")).ToString();
            }

            myConn1.Close();

            NpgsqlCommand cmd_get_subjectdata_avg_rz = new NpgsqlCommand(String.Format("select s.subject_name as subject, avg(m.pot_rz) as sum from \"Monitoring_SDZ\" as m LEFT JOIN \"Subject\" as s on m.subject_id=s.subject_id where s.subject_name = '{0}' GROUP BY subject", combox_sdz.SelectedItem.ToString()), myConn1);
            myConn1.Open();

            NpgsqlDataReader dataReaderGetSubject4 = cmd_get_subjectdata_avg_rz.ExecuteReader();

            while (dataReaderGetSubject4.Read())
            {
                avg_pot_rz.Text = dataReaderGetSubject4.GetValue(dataReaderGetSubject4.GetOrdinal("sum")).ToString();
            }

            myConn1.Close();

            NpgsqlCommand cmd_get_subjectdata_min_rz = new NpgsqlCommand(String.Format("select s.subject_name as subject, min(m.pot_rz) as sum from \"Monitoring_SDZ\" as m LEFT JOIN \"Subject\" as s on m.subject_id=s.subject_id where s.subject_name = '{0}' GROUP BY subject", combox_sdz.SelectedItem.ToString()), myConn1);
            myConn1.Open();

            NpgsqlDataReader dataReaderGetSubject5 = cmd_get_subjectdata_min_rz.ExecuteReader();

            while (dataReaderGetSubject5.Read())
            {
                min_pot_rz.Text = dataReaderGetSubject5.GetValue(dataReaderGetSubject5.GetOrdinal("sum")).ToString();
            }

            myConn1.Close();

            NpgsqlCommand cmd_get_subjectdata_max_rz = new NpgsqlCommand(String.Format("select s.subject_name as subject, max(m.pot_rz) as sum from \"Monitoring_SDZ\" as m LEFT JOIN \"Subject\" as s on m.subject_id=s.subject_id where s.subject_name = '{0}' GROUP BY subject", combox_sdz.SelectedItem.ToString()), myConn1);
            myConn1.Open();

            NpgsqlDataReader dataReaderGetSubject6 = cmd_get_subjectdata_max_rz.ExecuteReader();

            while (dataReaderGetSubject6.Read())
            {
                max_pot_rz.Text = dataReaderGetSubject6.GetValue(dataReaderGetSubject6.GetOrdinal("sum")).ToString();
            }

            myConn1.Close();
        }
        catch (NpgsqlException ex)
        {
        }
        finally
        {
            myConn1.Close();
        }
    }
Esempio n. 12
0
        protected void gridview_applykm_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e)
        {
            if (e.RowType == DevExpress.Web.ASPxGridView.GridViewRowType.Detail)
            {
                ASPxGridView    mastergrid = sender as ASPxGridView;
                ASPxPageControl tabs       = mastergrid.FindDetailRowTemplateControl(e.VisibleIndex, "tab_stepkhuyenmai") as ASPxPageControl;
                /* Setting for tab 1 */
                ASPxNavBar     navbar_info          = tabs.TabPages[0].FindControl("navbar_info") as ASPxNavBar;
                ASPxFormLayout form_infoquyenloi    = navbar_info.Groups[1].FindControl("form_infoquyenloi") as ASPxFormLayout;
                ASPxGridView   gridview_hanghoatang = form_infoquyenloi.FindControl("gridview_hanghoatang") as ASPxGridView;
                gridview_hanghoatang.DataSource = new[] {
                    new{ sequenceno    = "01", productid = "SP00001", productname = "Hàng hóa 1", productunitid = "Hộp", lotid = "L00001",
                         condition_buy = "5", condition_give = "1" },
                    new{ sequenceno    = "02", productid = "SP00002", productname = "Hàng hóa 2", productunitid = "Hộp", lotid = "L00002",
                         condition_buy = "10", condition_give = "1" },
                    new{ sequenceno    = "03", productid = "SP00003", productname = "Hàng hóa 3", productunitid = "Thùng", lotid = "L00003",
                         condition_buy = "100", condition_give = "1" },
                };
                gridview_hanghoatang.DataBind();
                gridview_hanghoatang.Visible = true;
                ASPxLabel lbl_title_khuyenmai2 = form_infoquyenloi.FindControl("lbl_title_khuyenmai2") as ASPxLabel;
                lbl_title_khuyenmai2.Visible = true;

                ASPxGridView gridview_hanghoabonus = form_infoquyenloi.FindControl("gridview_hanghoabonus") as ASPxGridView;
                gridview_hanghoabonus.DataSource =
                    new[] {
                    new { TenQuaTang = "Phiếu Giảm Giá", GiaTri = "15.000", SoLuong = "2", ThanhTien = "30.000", MoTa = "NAAN Solution" },
                    new { TenQuaTang = "Gấu Bông", GiaTri = "15.000", SoLuong = "3", ThanhTien = "45.000", MoTa = "NAAN Solution" },
                };
                gridview_hanghoabonus.DataBind();
                gridview_hanghoabonus.Visible = false;

                ASPxLabel      lbl_title_khuyenmai3 = form_infoquyenloi.FindControl("lbl_title_khuyenmai3") as ASPxLabel;
                ASPxRoundPanel round_chietkhau      = form_infoquyenloi.FindControl("round_chietkhau") as ASPxRoundPanel;
                round_chietkhau.Visible      = false;
                lbl_title_khuyenmai3.Visible = false;

                /* Setting for tab 2 */

                ASPxNavBar navbar_nextinfo = tabs.TabPages[1].FindControl("navi_nextinfo") as ASPxNavBar;
                form_infoquyenloi               = navbar_nextinfo.Groups[1].FindControl("form_infoquyenloi") as ASPxFormLayout;
                gridview_hanghoatang            = form_infoquyenloi.FindControl("gridview_hanghoatang") as ASPxGridView;
                gridview_hanghoatang.DataSource = new[] {
                    new{ sequenceno    = "01", productid = "SP00001", productname = "Hàng hóa 1", productunitid = "Hộp", lotid = "L00001",
                         condition_buy = "5", condition_give = "1" },
                    new{ sequenceno    = "02", productid = "SP00002", productname = "Hàng hóa 2", productunitid = "Hộp", lotid = "L00002",
                         condition_buy = "10", condition_give = "1" },
                    new{ sequenceno    = "03", productid = "SP00003", productname = "Hàng hóa 3", productunitid = "Thùng", lotid = "L00003",
                         condition_buy = "100", condition_give = "1" },
                };
                gridview_hanghoatang.DataBind();
                gridview_hanghoatang.Visible = false;
                lbl_title_khuyenmai2         = form_infoquyenloi.FindControl("lbl_title_khuyenmai2") as ASPxLabel;
                lbl_title_khuyenmai2.Visible = false;

                gridview_hanghoabonus            = form_infoquyenloi.FindControl("gridview_hanghoabonus") as ASPxGridView;
                gridview_hanghoabonus.DataSource =
                    new[] {
                    new { TenQuaTang = "Phiếu Giảm Giá", GiaTri = "15.000", SoLuong = "2", ThanhTien = "30.000", MoTa = "NAAN Solution" },
                    new { TenQuaTang = "Gấu Bông", GiaTri = "15.000", SoLuong = "3", ThanhTien = "45.000", MoTa = "NAAN Solution" },
                };
                gridview_hanghoabonus.DataBind();
                gridview_hanghoabonus.Visible = true;
                round_chietkhau         = form_infoquyenloi.FindControl("round_chietkhau") as ASPxRoundPanel;
                round_chietkhau.Visible = true;
            }
        }
Esempio n. 13
0
        protected void ASPxGridView1_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            try
            {
                using (var conexion = new DataModelFE())
                {
                    //se declara el objeto a insertar
                    EmisorReceptorIMEC dato = new EmisorReceptorIMEC();
                    //llena el objeto con los valores de la pantalla
                    dato.identificacionTipo = e.NewValues["identificacionTipo"].ToString();
                    dato.identificacion     = e.NewValues["identificacion"].ToString();
                    dato.nombre             = e.NewValues["nombre"].ToString();
                    dato.nombreComercial    = e.NewValues["nombreComercial"] != null ? e.NewValues["nombreComercial"].ToString().ToUpper() : null;

                    if (e.NewValues["telefono"] != null)
                    {
                        //dato.telefonoCodigoPais = e.NewValues["telefonoCodigoPais"].ToString();
                        dato.telefonoCodigoPais = "506";
                        dato.telefono           = e.NewValues["telefono"].ToString();
                    }

                    dato.correoElectronico = e.NewValues["correoElectronico"] != null ? e.NewValues["correoElectronico"].ToString() : null;

                    if (e.NewValues["fax"] != null)
                    {
                        //dato.faxCodigoPais = e.NewValues["faxCodigoPais"].ToString();
                        dato.faxCodigoPais = "506";
                        dato.fax           = e.NewValues["fax"].ToString();
                    }


                    ASPxPageControl tabs = (ASPxPageControl)ASPxGridView1.FindEditFormTemplateControl("pageControl");
                    ASPxFormLayout  form = (ASPxFormLayout)tabs.FindControl("formLayoutUbicacion");
                    /* PROVINCIA */
                    ASPxComboBox comboProvincia = (ASPxComboBox)form.FindControl("cmbProvincia");
                    /* CANTON */
                    ASPxComboBox comboCanton = (ASPxComboBox)form.FindControl("cmbCanton");
                    /* DISTRITO */
                    ASPxComboBox comboDistrito = (ASPxComboBox)form.FindControl("cmbDistrito");
                    /* BARRIO */
                    ASPxComboBox comboBarrio = (ASPxComboBox)form.FindControl("cmbBarrio");
                    ASPxMemo     otraSena    = (ASPxMemo)form.FindControl("txtOtraSenas");

                    dato.provincia = comboProvincia.Value.ToString();
                    dato.canton    = comboCanton.Value.ToString();
                    dato.distrito  = comboDistrito.Value.ToString();
                    dato.barrio    = comboBarrio.Value.ToString();
                    dato.otraSena  = otraSena.Text;


                    dato.estado          = e.NewValues["estado"].ToString();
                    dato.usuarioCreacion = Session["usuario"].ToString();
                    dato.fechaCreacion   = Date.DateTimeNow();

                    //agregar cliente
                    var existeEmisor = conexion.EmisorReceptorIMEC.Find(dato.identificacion);
                    if (existeEmisor == null)
                    {
                        conexion.EmisorReceptorIMEC.Add(dato);
                    }
                    else
                    {
                        conexion.Entry(dato).State = EntityState.Modified;
                    }
                    conexion.SaveChanges();


                    //asociar cliente
                    object[] key     = new object[] { Session["emisor"].ToString(), dato.identificacion };
                    var      cliente = conexion.Cliente.Find(key);
                    if (cliente == null)
                    {
                        cliente          = new Cliente();
                        cliente.emisor   = Session["emisor"].ToString();
                        cliente.receptor = dato.identificacion;
                        conexion.Cliente.Add(cliente);
                        conexion.SaveChanges();
                    }

                    //esto es para el manero del devexpress
                    e.Cancel = true;
                    this.ASPxGridView1.CancelEdit();

                    ((ASPxGridView)sender).JSProperties["cpUpdatedMessage"] = "Los datos se agregaron correctamente, puede continuar.";
                }
            }
            catch (DbEntityValidationException ex)
            {
                // Retrieve the error messages as a list of strings.
                var errorMessages = ex.EntityValidationErrors
                                    .SelectMany(x => x.ValidationErrors)
                                    .Select(x => x.ErrorMessage);

                // Join the list to a single string.
                var fullErrorMessage = string.Join("; ", errorMessages);

                // Throw a new DbEntityValidationException with the improved exception message.
                throw new DbEntityValidationException(fullErrorMessage, ex.EntityValidationErrors);
            }
            catch (Exception ex)
            {
                throw new Exception(Utilidades.validarExepcionSQL(ex), ex.InnerException);
            }
            finally
            {
                //refescar los datos
                this.refreshData();
            }
        }
Esempio n. 14
0
        /// <summary>
        /// desabilita los campos que no son editables
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ASPxGridView1_CellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e)
        {
            if (e.Column.FieldName == "identificacion")
            {
                ASPxPageControl tabs           = (ASPxPageControl)ASPxGridView1.FindEditFormTemplateControl("pageControl");
                ASPxFormLayout  form           = (ASPxFormLayout)tabs.FindControl("formLayoutUbicacion");
                ASPxComboBox    comboProvincia = (ASPxComboBox)form.FindControl("cmbProvincia");

                if (comboProvincia.Items.Count == 0)
                {
                    this.cargarProvincias();
                }

                EmisorReceptorIMEC dato = null;
                using (var conexion = new DataModelFE())
                {
                    if (e.Editor.Value != null)
                    {
                        dato = conexion.EmisorReceptorIMEC.Find(e.Editor.Value.ToString());
                        if (dato != null)
                        {
                            comboProvincia.Value = dato.provincia;
                        }
                    }
                }
            }

            if (this.ASPxGridView1.IsNewRowEditing)
            {
                if (e.Column.FieldName == "identificacion")
                {
                    this.cargarProvincias();
                }

                if (e.Column.FieldName == "estado")
                {
                    e.Editor.Value = "ACTIVO";
                }
            }
            else
            {/******************  CUANDO ES UNA MODIFICACION   *******************/
                if (this.ASPxGridView1.IsEditing && e.Column.FieldName == "identificacion" && !String.IsNullOrEmpty(e.Editor.Value.ToString()) && Session["entro"].ToString() == "NO")
                {
                    Session["entro"] = "SI";
                    EmisorReceptorIMEC dato = null;
                    using (var conexion = new DataModelFE())
                    {
                        dato = conexion.EmisorReceptorIMEC.Find(e.Editor.Value.ToString());
                    }

                    ASPxPageControl tabs = (ASPxPageControl)ASPxGridView1.FindEditFormTemplateControl("pageControl");
                    ASPxFormLayout  form = (ASPxFormLayout)tabs.FindControl("formLayoutUbicacion");

                    this.cargarProvincias();

                    /* PROVINCIA */
                    ASPxComboBox comboProvincia = (ASPxComboBox)form.FindControl("cmbProvincia");
                    comboProvincia.Value = dato.provincia;

                    /* CANTON */
                    ASPxComboBox comboCanton = (ASPxComboBox)form.FindControl("cmbCanton");
                    comboCanton.Items.Clear();

                    /* DISTRITO */
                    ASPxComboBox comboDistrito = (ASPxComboBox)form.FindControl("cmbDistrito");
                    comboDistrito.Items.Clear();

                    /* BARRIO */
                    ASPxComboBox comboBarrio = (ASPxComboBox)form.FindControl("cmbBarrio");
                    comboBarrio.Items.Clear();

                    /* OTRA SEÑAS */
                    ASPxMemo otraSena = (ASPxMemo)form.FindControl("txtOtraSenas");
                    otraSena.Text = dato.otraSena;


                    using (var conexion = new DataModelFE())
                    {
                        foreach (var item in conexion.Ubicacion.
                                 Where(x => x.codProvincia == dato.provincia).
                                 Select(x => new { x.codCanton, x.nombreCanton }).Distinct())
                        {
                            comboCanton.Items.Add(item.nombreCanton, item.codCanton);
                        }
                        comboCanton.IncrementalFilteringMode = IncrementalFilteringMode.Contains;
                        comboCanton.Value = dato.canton;


                        foreach (var item in conexion.Ubicacion.
                                 Where(x => x.codProvincia == dato.provincia).
                                 Where(x => x.codCanton == dato.canton).
                                 Select(x => new { x.codDistrito, x.nombreDistrito }).Distinct())
                        {
                            comboDistrito.Items.Add(item.nombreDistrito, item.codDistrito);
                        }
                        comboDistrito.IncrementalFilteringMode = IncrementalFilteringMode.Contains;
                        comboDistrito.Value = dato.distrito;


                        foreach (var item in conexion.Ubicacion.
                                 Where(x => x.codProvincia == dato.provincia).
                                 Where(x => x.codCanton == dato.canton).
                                 Where(x => x.codDistrito == dato.distrito).
                                 Select(x => new { x.codBarrio, x.nombreBarrio }).Distinct())
                        {
                            comboBarrio.Items.Add(item.nombreBarrio, item.codBarrio);
                        }
                        comboBarrio.IncrementalFilteringMode = IncrementalFilteringMode.Contains;
                        comboBarrio.Value = dato.barrio;
                    }
                }
            }
        }
Esempio n. 15
0
        protected void PopulaAbertura(Int32 Nro_Oportunidade)
        {
            #region "Definição de título"

            //****************
            //* Define título
            //****************
            if (Nro_Oportunidade == 0)
            {
                this.lblTitulo.Text = "CRIAÇÃO DE OPORTUNIDADE";
            }
            else
            {
                this.lblTitulo.Text = "ALTERANDO DADOS DA OPORTUNIDADE Nº " + Nro_Oportunidade;
            }
            #endregion

            #region "Situação da oportunidade"

            //********************************************************
            //* ABERTURA - Localiza combo da situação da oportunidade
            //********************************************************
            ASPxFormLayout oFormLayoutComando = nvbEtapas.Groups[0].FindControl("layComando") as ASPxFormLayout;
            if (oFormLayoutComando != null)
            {
                //*****************************
                //* Localiza combo da situação
                //*****************************
                ASPxComboBox oComboSituacao = oFormLayoutComando.FindControl("cboSituacao") as ASPxComboBox;
                if (oComboSituacao != null)
                {
                    //***************
                    //* Popula combo
                    //***************
                    ListLoader.Popula_CBO_OrcamentoSituacao(oComboSituacao);
                }
            }

            #endregion

            #region "Etapa 1 (Abertura)"

            //*****************************
            //* ABERTURA - Localiza layout
            //*****************************
            ASPxFormLayout oFormLayoutAbertura = nvbEtapas.Groups[1].FindControl("layAbertura") as ASPxFormLayout;
            if (oFormLayoutAbertura != null)
            {
                //*************************************
                //* Localiza combo do canal de entrada
                //*************************************
                ASPxComboBox oComboCanalEntrada = oFormLayoutAbertura.FindControl("cboCanalEntrada") as ASPxComboBox;
                if (oComboCanalEntrada != null)
                {
                    //***************
                    //* Popula combo
                    //***************
                    ListLoader.Popula_CBO_CanalEntrada(oComboCanalEntrada);
                }

                //*******************************
                //* Localiza combo de atendentes
                //*******************************
                ASPxComboBox oComboAtendente = oFormLayoutAbertura.FindControl("cboAtendente") as ASPxComboBox;
                if (oComboAtendente != null)
                {
                    //***************
                    //* Popula combo
                    //***************
                    ListLoader.Popula_CBO_Atendentes(oComboAtendente, Session["Decision_LoginInfo"]);
                }
            }

            #endregion

            #region "Etapa 2 (Orçamento)

            //****************************************
            //* ORÇAMENTO - Localiza layout de campos
            //****************************************
            ASPxFormLayout oFormLayoutOrcamento0 = nvbEtapas.Groups[2].FindControl("layOrcamento0") as ASPxFormLayout;
            if (oFormLayoutOrcamento0 != null)
            {
                //*****************************************
                //* Localiza combo de estágio de orçamento
                //*****************************************
                ASPxComboBox oComboEstagioOrcamento = oFormLayoutOrcamento0.FindControl("cboEstagioOrcamento") as ASPxComboBox;
                if (oComboEstagioOrcamento != null)
                {
                    //***************
                    //* Popula combo
                    //***************
                    ListLoader.Popula_CBO_EstagioOrcamento(oComboEstagioOrcamento);
                }
            }

            #endregion
        }
Esempio n. 16
0
        /// <summary>
        /// inserta un registro nuevo
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ASPxGridView1_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            try
            {
                using (var conexion = new DataModelFE())
                {
                    //se declara el objeto a insertar
                    EmisorReceptorIMEC dato = new EmisorReceptorIMEC();
                    //llena el objeto con los valores de la pantalla
                    dato.identificacionTipo = e.NewValues["identificacionTipo"].ToString();
                    dato.identificacion     = e.NewValues["identificacion"].ToString();
                    dato.nombre             = e.NewValues["nombre"].ToString();
                    dato.nombreComercial    = e.NewValues["nombreComercial"] != null ? e.NewValues["nombreComercial"].ToString().ToUpper() : null;

                    if (e.NewValues["telefono"] != null)
                    {
                        //dato.telefonoCodigoPais = e.NewValues["telefonoCodigoPais"].ToString();
                        dato.telefonoCodigoPais = "506";
                        dato.telefono           = e.NewValues["telefono"].ToString();
                    }

                    dato.correoElectronico = e.NewValues["correoElectronico"] != null ? e.NewValues["correoElectronico"].ToString()  : null;

                    if (e.NewValues["fax"] != null)
                    {
                        //dato.faxCodigoPais = e.NewValues["faxCodigoPais"].ToString();
                        dato.faxCodigoPais = "506";
                        dato.fax           = e.NewValues["fax"].ToString();
                    }


                    ASPxPageControl tabs = (ASPxPageControl)ASPxGridView1.FindEditFormTemplateControl("pageControl");
                    ASPxFormLayout  form = (ASPxFormLayout)tabs.FindControl("formLayoutUbicacion");
                    /* PROVINCIA */
                    ASPxComboBox comboProvincia = (ASPxComboBox)form.FindControl("cmbProvincia");
                    /* CANTON */
                    ASPxComboBox comboCanton = (ASPxComboBox)form.FindControl("cmbCanton");
                    /* DISTRITO */
                    ASPxComboBox comboDistrito = (ASPxComboBox)form.FindControl("cmbDistrito");
                    /* BARRIO */
                    ASPxComboBox comboBarrio = (ASPxComboBox)form.FindControl("cmbBarrio");
                    ASPxMemo     otraSena    = (ASPxMemo)form.FindControl("txtOtraSenas");

                    /* PLAN */
                    ASPxComboBox combPlan = (ASPxComboBox)form.FindControl("cmbPlan");


                    dato.provincia = comboProvincia.Value.ToString();
                    dato.canton    = comboCanton.Value.ToString();
                    dato.distrito  = comboDistrito.Value.ToString();
                    dato.barrio    = comboBarrio.Value.ToString();
                    dato.otraSena  = otraSena.Text;

                    dato.usernameOAuth2          = e.NewValues["usernameOAuth2"] != null ? e.NewValues["usernameOAuth2"].ToString() : null;
                    dato.passwordOAuth2          = e.NewValues["passwordOAuth2"] != null ?  e.NewValues["passwordOAuth2"].ToString() : null;
                    dato.claveLlaveCriptografica = e.NewValues["claveLlaveCriptografica"] != null ?  e.NewValues["claveLlaveCriptografica"].ToString() : null;

                    if (Session["LlaveCriptograficap12"] != null)
                    {
                        dato.llaveCriptografica = (byte[])Session["LlaveCriptograficap12"];
                    }

                    dato.estado          = e.NewValues["estado"].ToString();
                    dato.usuarioCreacion = Session["usuario"].ToString();
                    dato.fechaCreacion   = Date.DateTimeNow();

                    //agrega el objeto
                    EmisorReceptorIMEC existeEmisor = conexion.EmisorReceptorIMEC.Find(dato.identificacion);
                    if (existeEmisor == null)
                    {
                        conexion.EmisorReceptorIMEC.Add(dato);
                    }
                    else
                    {
                        conexion.Entry(dato).State = EntityState.Modified;
                    }


                    Plan planE = conexion.Plan.Find(dato.identificacion);
                    if (planE == null)
                    {
                        TipoPlan tipoPlan = conexion.TipoPlan.Find(combPlan.Value.ToString());

                        Plan plan = new Plan();
                        plan.usuarioCreacion    = Session["usuario"].ToString();
                        plan.fechaCreacion      = Date.DateTimeNow();
                        plan.cantidadDocEmitido = 0;
                        plan.cantidadDocPlan    = tipoPlan.cantidad;
                        plan.plan        = tipoPlan.codigo;
                        plan.emisor      = dato.identificacion;
                        plan.estado      = Estado.ACTIVO.ToString();
                        plan.fechaInicio = Date.DateTimeNow();
                        plan.fechaFin    = Date.DateTimeNow().AddYears(1);
                        conexion.Plan.Add(plan);
                    }

                    Usuario usuario = conexion.Usuario.Find(dato.identificacion);
                    if (usuario == null)
                    {
                        usuario = new Usuario();
                        usuario.usuarioCreacion = Session["usuario"].ToString();
                        usuario.fechaCreacion   = Date.DateTimeNow();
                        usuario.nombre          = dato.nombre;
                        usuario.emisor          = dato.identificacion;
                        usuario.codigo          = dato.identificacion;
                        usuario.contrasena      = MD5Util.getMd5Hash("msa" + dato.identificacion + ".01");
                        usuario.correo          = dato.correoElectronico;
                        usuario.rol             = Rol.FACTURADOR;
                        conexion.Usuario.Add(usuario);
                    }

                    ConsecutivoDocElectronico consecutivo = conexion.ConsecutivoDocElectronico.Where(x => x.emisor == dato.identificacion && x.tipoDocumento == "01").FirstOrDefault();
                    if (consecutivo == null)
                    {
                        consecutivo                   = new ConsecutivoDocElectronico();
                        consecutivo.emisor            = dato.identificacion;
                        consecutivo.sucursal          = "001";
                        consecutivo.caja              = "00001";
                        consecutivo.consecutivo       = 1;
                        consecutivo.tipoDocumento     = TipoDocumento.FACTURA_ELECTRONICA;
                        consecutivo.digitoVerificador = "00000000";
                        consecutivo.estado            = Estado.ACTIVO.ToString();
                        consecutivo.usuarioCreacion   = Session["usuario"].ToString();
                        consecutivo.fechaCreacion     = Date.DateTimeNow();
                        conexion.ConsecutivoDocElectronico.Add(consecutivo);
                    }

                    Empresa empresa = conexion.Empresa.Find(dato.identificacion);
                    if (empresa == null)
                    {
                        empresa                 = new Empresa();
                        empresa.codigo          = dato.identificacion;
                        empresa.descripcion     = dato.nombre == null ? dato.nombreComercial : dato.nombre;
                        empresa.estado          = Estado.ACTIVO.ToString();
                        empresa.usuarioCreacion = Session["usuario"].ToString();
                        empresa.fechaCreacion   = Date.DateTimeNow();
                        empresa.idioma          = Empresa.IDIOMA_ESPANOL;
                        empresa.medioPago       = "01";
                        empresa.condicionVenta  = "01";
                        empresa.plazoCredito    = 0;
                        empresa.tipoImpresion   = "A4";
                        empresa.moneda          = "CRC";
                        conexion.Empresa.Add(empresa);
                    }

                    string     super      = Session["usuario"].ToString();
                    Supervisor supervisor = conexion.Supervisor.Where(x => x.supervisor == super && x.emisor == dato.identificacion).FirstOrDefault();
                    if (supervisor == null)
                    {
                        supervisor            = new Supervisor();
                        supervisor.supervisor = Session["usuario"].ToString();
                        supervisor.emisor     = dato.identificacion;
                        conexion.Supervisor.Add(supervisor);
                    }

                    conexion.SaveChanges();

                    //esto es para el manero del devexpress
                    e.Cancel = true;
                    this.ASPxGridView1.CancelEdit();

                    ((ASPxGridView)sender).JSProperties["cpUpdatedMessage"] = "Los datos se agregaron correctamente, puede continuar.";
                }
            }
            catch (DbEntityValidationException ex)
            {
                // Retrieve the error messages as a list of strings.
                var errorMessages = ex.EntityValidationErrors
                                    .SelectMany(x => x.ValidationErrors)
                                    .Select(x => x.ErrorMessage);

                // Join the list to a single string.
                var fullErrorMessage = string.Join("; ", errorMessages);

                // Throw a new DbEntityValidationException with the improved exception message.
                throw new DbEntityValidationException(fullErrorMessage, ex.EntityValidationErrors);
            }
            catch (Exception ex)
            {
                throw new Exception(Utilidades.validarExepcionSQL(ex), ex.InnerException);
            }
            finally
            {
                //refescar los datos
                this.refreshData();
            }
        }