Exemplo n.º 1
0
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == "alpha" || e.CommandName == "NoFilter")
        {
            String value = null;
            switch (e.CommandName)
            {
            case ("alpha"):
            {
                value = string.Format("{0}%", e.CommandArgument);
                break;
            }

            case ("NoFilter"):
            {
                value = "%";
                break;
            }
            }
            ObjectDataSource1.SelectParameters["HoTen"].DefaultValue = value;
            ObjectDataSource1.DataBind();
            RadGrid1.Rebind();
        }
        else if (e.CommandName == "QuickUpdate")
        {
            string DatLichKhamID, Priority, IsAvailable;
            var    oDatLichKham = new DatLichKham();

            foreach (GridDataItem item in RadGrid1.Items)
            {
                DatLichKhamID = item.GetDataKeyValue("DatLichKhamID").ToString();
                Priority      = ((RadNumericTextBox)item.FindControl("txtPriority")).Text.Trim();
                IsAvailable   = ((CheckBox)item.FindControl("chkIsAvailable")).Checked.ToString();

                oDatLichKham.DatLichKhamQuickUpdate(
                    DatLichKhamID,
                    IsAvailable,
                    Priority
                    );
            }
        }
        //else if (e.CommandName == "DeleteSelected")
        //{
        //    var oDatLichKham = new DatLichKham();

        //    foreach (GridDataItem item in RadGrid1.SelectedItems)
        //    {
        //        string strDatLichKhamImage = ((HiddenField)item.FindControl("hdnDatLichKhamImage")).Value;

        //        if (!string.IsNullOrEmpty(strDatLichKhamImage))
        //        {
        //            string strSavePath = Server.MapPath("~/res/DatLichKham/" + strDatLichKhamImage);
        //            if (File.Exists(strSavePath))
        //                File.Delete(strSavePath);
        //        }
        //    }
        //}
        else if (e.CommandName == "PerformInsert" || e.CommandName == "Update")
        {
            var command = e.CommandName;
            var row     = command == "PerformInsert" ? (GridEditFormInsertItem)e.Item : (GridEditFormItem)e.Item;

            string strDatLich    = ((RadioButtonList)row.FindControl("radioDatLich")).SelectedValue;
            string strHoTen      = ((TextBox)row.FindControl("txtHoTen")).Text.Trim();
            var    dpNgaySinh    = (RadDatePicker)row.FindControl("dpNgaySinh");
            string strNgaySinh   = dpNgaySinh.SelectedDate.HasValue ? dpNgaySinh.SelectedDate.Value.ToShortDateString() : "";
            string strGioiTinh   = ((RadioButtonList)row.FindControl("radioGioiTinh")).SelectedValue;
            string strDienThoai  = ((TextBox)row.FindControl("txtDienThoai")).Text.Trim();
            string strEmail      = ((TextBox)row.FindControl("txtEmail")).Text.Trim();
            string strChuyenKhoa = ((DropDownList)row.FindControl("dropChuyenKhoa")).SelectedValue;
            string strBacSi      = ((DropDownList)row.FindControl("dropBacSi")).SelectedValue;
            string strMoTa       = ((TextBox)row.FindControl("txtMoTa")).Text.Trim();

            var dpNgayKham  = (RadDatePicker)row.FindControl("dpNgayKham");
            var dpGioKham   = (RadTimePicker)row.FindControl("dpGioKham");
            var strNgayKham = dpNgayKham.SelectedDate.HasValue ? dpNgayKham.SelectedDate.Value.ToShortDateString() : "";
            var strGioKham  = dpGioKham.SelectedDate.HasValue ? dpGioKham.SelectedDate.Value.ToShortTimeString() : "";
            strNgayKham = string.IsNullOrEmpty(strNgayKham) ? "" : strNgayKham + " " + strGioKham;
            string strIsAvailable = ((CheckBox)row.FindControl("chkIsAvailable")).Checked.ToString();
            string strPriority    = ((RadNumericTextBox)row.FindControl("txtPriority")).Text.Trim();

            var oDatLichKham = new DatLichKham();

            if (e.CommandName == "PerformInsert")
            {
                oDatLichKham.DatLichKhamInsert(
                    strDatLich,
                    strHoTen,
                    strNgaySinh,
                    strGioiTinh,
                    strDienThoai,
                    strEmail,
                    strChuyenKhoa,
                    strBacSi,
                    strMoTa,
                    strNgayKham,
                    "",
                    strIsAvailable,
                    strPriority
                    );
                RadGrid1.Rebind();

                //var dsInsertParam = ObjectDataSource1.InsertParameters;
                //dsInsertParam["DatLichCho"].DefaultValue = strDatLich;
                //dsInsertParam["HoTen"].DefaultValue = strHoTen;
                //dsInsertParam["NgaySinh"].DefaultValue = strNgaySinh;
                //dsInsertParam["GioiTinh"].DefaultValue = strGioiTinh;
                //dsInsertParam["DienThoai"].DefaultValue = strDienThoai;
                //dsInsertParam["Email"].DefaultValue = strEmail;
                //dsInsertParam["ProjectCategoryID"].DefaultValue = strChuyenKhoa;
                //dsInsertParam["ProjectID"].DefaultValue = strBacSi;
                //dsInsertParam["MoTa"].DefaultValue = strMoTa;
                //dsInsertParam["NgayKham"].DefaultValue = strNgayKham;
                //dsInsertParam["IsAvailable"].DefaultValue = strIsAvailable;
                //dsInsertParam["Priority"].DefaultValue = strPriority;
            }
            else
            {
                var dsUpdateParam    = ObjectDataSource1.UpdateParameters;
                var strDatLichKhamID = row.GetDataKeyValue("DatLichKhamID").ToString();
                //var strOldDatLichKhamImage = ((HiddenField)row.FindControl("hdnDatLichKhamImage")).Value;
                //var strOldImagePath = Server.MapPath("~/res/DatLichKham/" + strOldDatLichKhamImage);

                dsUpdateParam["DatLichCho"].DefaultValue        = strDatLich;
                dsUpdateParam["HoTen"].DefaultValue             = strHoTen;
                dsUpdateParam["NgaySinh"].DefaultValue          = strNgaySinh;
                dsUpdateParam["GioiTinh"].DefaultValue          = strGioiTinh;
                dsUpdateParam["DienThoai"].DefaultValue         = strDienThoai;
                dsUpdateParam["Email"].DefaultValue             = strEmail;
                dsUpdateParam["ProjectCategoryID"].DefaultValue = strChuyenKhoa;
                dsUpdateParam["ProjectID"].DefaultValue         = strBacSi;
                dsUpdateParam["MoTa"].DefaultValue        = strMoTa;
                dsUpdateParam["NgayKham"].DefaultValue    = strNgayKham;
                dsUpdateParam["IsAvailable"].DefaultValue = strIsAvailable;
                dsUpdateParam["Priority"].DefaultValue    = strPriority;
            }
        }
        //if (e.CommandName == "DeleteImage")
        //{
        //    var oDatLichKham = new DatLichKham();
        //    var lnkDeleteImage = (LinkButton)e.CommandSource;
        //    var s = lnkDeleteImage.Attributes["rel"].ToString().Split('#');
        //    var strDatLichKhamID = s[0];
        //    var strDatLichKhamImage = s[1];

        //    oDatLichKham.DatLichKhamImageDelete(strDatLichKhamID);
        //    DeleteImage(strDatLichKhamImage);
        //    RadGrid1.Rebind();
        //}
    }
Exemplo n.º 2
0
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == "alpha" || e.CommandName == "NoFilter")
        {
            String value = null;
            switch (e.CommandName)
            {
            case ("alpha"):
            {
                value = string.Format("{0}%", e.CommandArgument);
                break;
            }

            case ("NoFilter"):
            {
                value = "%";
                break;
            }
            }
            ObjectDataSource1.SelectParameters["HoTen"].DefaultValue = value;
            ObjectDataSource1.DataBind();
            RadGrid1.Rebind();
        }
        else if (e.CommandName == "QuickUpdate")
        {
            string DatLichKhamID, Priority, IsAvailable;
            var    oDatLichKham = new DatLichKham();

            foreach (GridDataItem item in RadGrid1.Items)
            {
                DatLichKhamID = item.GetDataKeyValue("DatLichKhamID").ToString();
                Priority      = ((RadNumericTextBox)item.FindControl("txtPriority")).Text.Trim();
                IsAvailable   = ((CheckBox)item.FindControl("chkIsAvailable")).Checked.ToString();

                oDatLichKham.DatLichKhamQuickUpdate(
                    DatLichKhamID,
                    IsAvailable,
                    Priority
                    );
            }
        }
        //else if (e.CommandName == "PerformInsert" || e.CommandName == "Update")
        //{
        //    var command = e.CommandName;
        //    var row = command == "PerformInsert" ? (GridEditFormInsertItem)e.Item : (GridEditFormItem)e.Item;

        //    string strIsAvailable = ((CheckBox)row.FindControl("chkIsAvailable")).Checked.ToString();
        //    string OriginNameEn = "";

        //    if (e.CommandName == "PerformInsert")
        //    {
        //        ObjectDataSource1.InsertParameters["IsAvailable"].DefaultValue = strIsAvailable;
        //        ObjectDataSource1.InsertParameters["OriginNameEn"].DefaultValue = OriginNameEn;
        //    }
        //    else
        //    {
        //        ObjectDataSource1.UpdateParameters["IsAvailable"].DefaultValue = strIsAvailable;
        //        ObjectDataSource1.UpdateParameters["OriginNameEn"].DefaultValue = OriginNameEn;
        //    }
        //}
        //else if (e.CommandName == "DeleteSelected")
        //{
        //    var oOrigin = new Origin();
        //    string errorList = "", OriginName = "";

        //    foreach (GridDataItem item in RadGrid1.SelectedItems)
        //    {
        //        try
        //        {
        //            var OriginID = item.GetDataKeyValue("OriginID").ToString();
        //            OriginName = item["OriginName"].Text;
        //            oOrigin.OriginDelete(OriginID);
        //        }
        //        catch (Exception ex)
        //        {
        //            lblError.Text = ex.Message;
        //            if (ex.Message == ((int)ErrorNumber.ConstraintConflicted).ToString())
        //                errorList += ", " + OriginName;
        //        }
        //    }
        //    if (!string.IsNullOrEmpty(errorList))
        //    {
        //        e.Canceled = true;
        //        string strAlertMessage = "Xuất Xứ <b>\"" + errorList.Remove(0, 1).Trim() + " \"</b> đang chứa Sản Phẩm.<br /> Xin xóa Sản phẩm trong Xuất Xứ này hoặc thiết lập hiển thị = \"không\".";
        //        lblError.Text = strAlertMessage;
        //    }
        //}
    }