protected void gvResearch_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridViewColumnDataEventArgs e)
        {
            int proStatus = Convert.ToInt32(e.GetListSourceFieldValue("ProfessorStatusID"));
            int round = Convert.ToInt32(e.GetListSourceFieldValue("RoundID"));
            int percent = Convert.ToInt32(e.GetListSourceFieldValue("Percentage"));
            double head = 10.5;
            double sub = 1.75;

            if (e.Column.FieldName == "ResCredit")
            {
                if (round == 1)
                {
                    if (proStatus == 1)
                    {
                        if (percent >= 75)
                        {
                            e.Value = head + 7;
                        }
                        else if (percent <= 74 && percent >= 51)
                        {
                            e.Value = head + 5.25;
                        }
                        else if (percent <= 50 && percent >= 25)
                        {
                            e.Value = head + 3.5;
                        }
                        else
                        {
                            e.Value = head + sub;
                        }
                    }
                    else
                    {
                        if (percent >= 75)
                        {
                            e.Value = 7;
                        }
                        else if (percent <= 74 && percent >= 51)
                        {
                            e.Value = 5.25;
                        }
                        else if (percent <= 50 && percent >= 25)
                        {
                            e.Value = 3.5;
                        }
                        else
                        {
                            e.Value = sub;
                        }
                    }
                }
            }
        }
    protected void ASPxGridView1_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewColumnDataEventArgs e)
    {
        decimal total = Convert.ToDecimal(e.GetListSourceFieldValue("DSBAN"));
        decimal discount = Convert.ToDecimal(e.GetListSourceFieldValue("Discount1"));
        decimal discount2 = Convert.ToDecimal(e.GetListSourceFieldValue("Discount2"));
        decimal returnTotal = Convert.ToDecimal(e.GetListSourceFieldValue("ReturnTotal"));
        decimal importPrice = Convert.ToDecimal(e.GetListSourceFieldValue("ImportPrice"));

        if (e.Column.FieldName == "FinalTotal")
        {
            e.Value = total - (discount+discount2) - returnTotal;
        }

        if (e.Column.FieldName == "Rate")
        {
            e.Value = total - (discount + discount2) - returnTotal - importPrice;
        }

        //if (e.Column.FieldName == "PercentRate")
        //{
        //    decimal rate = total - discount - returnTotal - importPrice;
        //    if (importPrice == 0)
        //        e.Value = 0;
        //    else e.Value = rate * 100 / importPrice;
        //}
    }
    protected void ASPxGridView1_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewColumnDataEventArgs e)
    {
        decimal dathu = Convert.ToDecimal(e.GetListSourceFieldValue("TienDaThu"));
        decimal datra = Convert.ToDecimal(e.GetListSourceFieldValue("TienDaTra"));

        if (e.Column.FieldName == "FinalTotal")
        {
            e.Value = dathu-datra;
        }
    }
 protected void ASPxGridView1_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewColumnDataEventArgs e)
 {
     decimal total = Convert.ToDecimal(e.GetListSourceFieldValue("Total"));
     decimal discount1 = Convert.ToDecimal(e.GetListSourceFieldValue("Discount1"));
     decimal discount2 = Convert.ToDecimal(e.GetListSourceFieldValue("Discount2"));
     if (e.Column.FieldName == "FinalTotal")
     {
         e.Value = total - (discount1 + discount2);
     }
 }
    protected void ASPxGridView1_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewColumnDataEventArgs e)
    {
        decimal gtdk = Convert.ToDecimal(e.GetListSourceFieldValue("gtTonDK"));
        decimal gtntk = Convert.ToDecimal(e.GetListSourceFieldValue("gtNhapTK"));
        decimal gtxtk = Convert.ToDecimal(e.GetListSourceFieldValue("gtXuatTK"));

        if (e.Column.FieldName == "gtCK")
        {
            e.Value = gtdk + gtntk - gtxtk;
        }
    }
 protected void ASPxGridView1_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewColumnDataEventArgs e)
 {
     decimal doanhsoban = Convert.ToDecimal(e.GetListSourceFieldValue("DoanhSoBan"));
     decimal khuyenmai = Convert.ToDecimal(e.GetListSourceFieldValue("KhuyenMai"));
     decimal chietkhau = Convert.ToDecimal(e.GetListSourceFieldValue("ChietKhau"));
     decimal doanhsotrahang = Convert.ToDecimal(e.GetListSourceFieldValue("DoanhSoTraHang"));
     decimal chietkhautrahang = Convert.ToDecimal(e.GetListSourceFieldValue("ChietKhauTraHang"));
     decimal trahangkhuyenmai = Convert.ToDecimal(e.GetListSourceFieldValue("TraHangKhuyenMai"));
     decimal giavonhangtra = Convert.ToDecimal(e.GetListSourceFieldValue("GiaVonHangTra"));
     decimal giavonhangban = Convert.ToDecimal(e.GetListSourceFieldValue("GiaVonHangBan"));
     if (e.Column.FieldName == "DoanhSo")
     {
         e.Value = doanhsoban - doanhsotrahang;
     }
     if (e.Column.FieldName == "GiaVon")
     {
         e.Value = giavonhangban - giavonhangtra;
     }
     if (e.Column.FieldName == "TongKhuyenMai")
     {
         e.Value = khuyenmai - trahangkhuyenmai;
     }
     if (e.Column.FieldName == "TongChietKhau")
     {
         e.Value = chietkhau - chietkhautrahang;
     }
     if (e.Column.FieldName == "LaiLo")
     {
         e.Value =  (doanhsoban - doanhsotrahang)-(giavonhangban - giavonhangtra)-(khuyenmai - trahangkhuyenmai)-(chietkhau - chietkhautrahang);
     }
 }
        protected void gvDirectTeaching_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridViewColumnDataEventArgs e)
        {
            int StdNumber = Convert.ToInt32(e.GetListSourceFieldValue("StdNumber"));
            double result = 0;

            if (e.Column.FieldName == "TheoryCpW"){

                if (StdNumber >= 101){
                    result = 6.5F;
                }else if (StdNumber <= 100 && StdNumber >= 71){
                    result = 5.5F;
                }else if (StdNumber <= 70 && StdNumber >= 41){
                    result = 4.5F;
                }else if (StdNumber <= 40 && StdNumber > 0){
                    result = 3.5F;
                }
                theoResult = result;
                e.Value = result;
            }

            if (e.Column.FieldName == "PracticeCpW")
            {
                if (StdNumber>0)
                {
                    result = 1.75F;
                }
                pracResult = result;
                e.Value = result;
            }

            if (e.Column.FieldName == "TotalinRow")
            {

                int theoryCredit = Convert.ToInt32(e.GetListSourceFieldValue("TheoryCredit"));
                int practiceCredit = Convert.ToInt32(e.GetListSourceFieldValue("PracticeCredit"));
                int theoryWeek = Convert.ToInt32(e.GetListSourceFieldValue("TheoryWeek"));
                int practiceWeek = Convert.ToInt32(e.GetListSourceFieldValue("PracticeWeek"));

                double tmpMultiTheo = (theoryWeek * (theoResult * theoryCredit)) / 15;
                double tmpMultiPrac = (practiceWeek * (pracResult * practiceCredit)) / 15;

                string str = String.Format("{0:F2}", tmpMultiTheo + tmpMultiPrac);
                e.Value = str;

            }
        }
    protected void ASPxGridView1_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewColumnDataEventArgs e)
    {
        decimal total = Convert.ToDecimal(e.GetListSourceFieldValue("TotalPayment"));
        decimal discount1 = Convert.ToDecimal(e.GetListSourceFieldValue("DiscountValue1"));
        decimal discount2 = Convert.ToDecimal(e.GetListSourceFieldValue("DiscountValue2"));
        decimal tax = Convert.ToDecimal(e.GetListSourceFieldValue("Tax"));
        decimal returnTotal = Convert.ToDecimal(e.GetListSourceFieldValue("Returnpayment"));
        decimal importPrice = Convert.ToDecimal(e.GetListSourceFieldValue("ImportPrice"));

        if (e.Column.FieldName == "PaymentTotal")
        {
            e.Value = total + tax - discount1 - discount2;
        }
        if (e.Column.FieldName == "FinalTotal")
        {
            e.Value = total + tax - discount1 - discount2 - returnTotal;
        }

        if (e.Column.FieldName == "Rate")
        {
            e.Value = total + tax - discount1 - discount2 - returnTotal - importPrice;
        }

        if (e.Column.FieldName == "PercentRate")
        {
            decimal rate = total + tax - discount1 - discount2 - returnTotal - importPrice;
            if (importPrice == 0)
                e.Value = 0;
            else e.Value = rate * 100 / importPrice;
        }
    }
        protected void gvCulture_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridViewColumnDataEventArgs e)
        {
            int proNumber = Convert.ToInt32(e.GetListSourceFieldValue("ProjectNumber"));
            double CarryCredit = 1.5;

            if (e.Column.FieldName == "CarryCredit")
            {
                e.Value = CarryCredit;
            }
            if (e.Column.FieldName == "Total")
            {
                e.Value = proNumber*CarryCredit;
            }
        }
    protected void ASPxGridView1_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewColumnDataEventArgs e)
    {
        decimal SlXuat = e.GetListSourceFieldValue("SlXuat")==DBNull.Value? 0 : Convert.ToInt32(e.GetListSourceFieldValue("SlXuat"));
        decimal SlTang = e.GetListSourceFieldValue("SlTang") == DBNull.Value ? 0 : Convert.ToInt32(e.GetListSourceFieldValue("SlTang"));
        decimal TongXuat = e.GetListSourceFieldValue("TongXuat") == DBNull.Value ? 0 : Convert.ToDecimal(e.GetListSourceFieldValue("TongXuat"));
        decimal TongTang = e.GetListSourceFieldValue("TongTang") == DBNull.Value ? 0 : Convert.ToDecimal(e.GetListSourceFieldValue("TongTang"));

        if (e.Column.FieldName == "SL")
        {
            e.Value = SlXuat+SlTang;
        }

        if (e.Column.FieldName == "TT")
        {
            e.Value = TongTang+TongXuat;
        }
    }
        protected void gvSupervision_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridViewColumnDataEventArgs e)
        {
            double StdNumber = Convert.ToDouble(e.GetListSourceFieldValue("StdNumber"));
            double CarryCredit = 3.5;

            if (e.Column.FieldName == "CarryCredit")
            {
                e.Value = CarryCredit;
            }

            if (e.Column.FieldName == "CpW")
            {
                e.Value = StdNumber * CarryCredit;
            }
        }
        protected void gvAdvisorProject_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridViewColumnDataEventArgs e)
        {
            int status = Convert.ToInt32(e.GetListSourceFieldValue("StatusID"));

            if (e.Column.FieldName == "CpW")
            {
                if (status == 0)
                {
                    e.Value = 3;
                }
                else
                {
                    e.Value = 1.5;
                }
            }
        }
        private void grdAnimationCustomerGroups_CustomUnboundColumnData(object sender, DevExpress.Xpf.Grid.GridColumnDataEventArgs e)
        {
            //Guid IDCustomerGroup = (Guid)e.GetListSourceFieldValue("IDCustomerGroup");
            //CustomerGroup cg = AnimationManager.GetInstance().GetCustomerGroupByID(IDCustomerGroup);
            CustomerGroup cg = e.GetListSourceFieldValue("CustomerGroup") as CustomerGroup;

            if (cg != null)
            {
                string fieldName = e.Column.FieldName;
                if (fieldName == "CustomerGroupName")
                {
                    if (e.IsGetData)
                    {
                        e.Value = cg.Name;
                    }
                }
                else if (fieldName == "CustomerGroupCode")
                {
                    if (e.IsGetData)
                    {
                        e.Value = cg.Code;
                    }
                }
                else if (fieldName == "CustomerGroupSalesAreaName")
                {
                    if (e.IsGetData)
                    {
                        e.Value = cg.SalesArea.Name;
                    }
                }
            }
        }
        protected void gvResearchPublish_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridViewColumnDataEventArgs e)
        {
            if (e.Column.FieldName == "CpW")
            {
                strConnString = WebConfigurationManager.ConnectionStrings["AssessmentSystem"].ConnectionString;
                objConn = new SqlConnection(strConnString);
                objConn.Open();

                int resStatus = Convert.ToInt32(e.GetListSourceFieldValue("ResStatusID"));
                int resType = Convert.ToInt32(e.GetListSourceFieldValue("ResTypeID"));

                try
                {
                    id = Convert.ToInt32(e.GetListSourceFieldValue("ResNumber"));
                }
                catch (Exception)
                {

                }

                strSQL = "SELECT * FROM Research WHERE id = '" + id + "'";
                dtAdapter = new SqlDataAdapter(strSQL, objConn);
                dtAdapter.Fill(dt);

                if (resStatus == 1 && id != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        int proStatus = Convert.ToInt32(dt.Rows[i]["ProfessorStatusID"]);
                        int round = Convert.ToInt32(dt.Rows[i]["RoundID"]);
                        int percent = Convert.ToInt32(dt.Rows[i]["Percentage"]);

                        double head = 10.5;
                        double sub = 1.75;
                        double tmp = 0;

                        if (round == 1 || round == 2)
                        {
                            if (proStatus == 1)
                            {
                                if (percent >= 75)
                                {
                                    tmp = head + 7;
                                }
                                else if (percent <= 74 && percent >= 51)
                                {
                                    tmp = head + 5.25;
                                }
                                else if (percent <= 50 && percent >= 25)
                                {
                                    tmp = head + 3.5;
                                }
                                else
                                {
                                    tmp = head + sub;
                                }
                            }
                            else
                            {
                                if (percent >= 75)
                                {
                                    tmp = 7;
                                }
                                else if (percent <= 74 && percent >= 51)
                                {
                                    tmp = 5.25;
                                }
                                else if (percent <= 50 && percent >= 25)
                                {
                                    tmp = 3.5;
                                }
                                else
                                {
                                    tmp = sub;
                                }
                            }

                            if (resType == 1)
                            {
                                e.Value = tmp * 0.5;
                            }
                            else
                            {
                                e.Value = tmp;
                            }
                        }
                    }
                    i++;
                }
                else
                {
                    if (resType == 1)
                    {
                        e.Value = 3.5;
                    }
                    else
                    {
                        e.Value = 7;
                    }
                }

            }
        }
 protected void ASPxGridView1_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewColumnDataEventArgs e)
 {
     if (e.Column.FieldName == "CompositeKey")
     {
         e.Value = e.GetListSourceFieldValue("idCarrera").ToString() + e.GetListSourceFieldValue("idCurso").ToString();
     }
 }
    protected void GVEditor_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewColumnDataEventArgs e)
    {
        if (e.Column.FieldName == "Saf")
        {
            string StudentCode = e.GetListSourceFieldValue("stid").ToString();
            DataTable SafTbl = MCfrsan.LoadDataTable(@"SELECT alsofof_code, alsofof_name FROM alsofof", false);

            DataTable dt = MCfrsan.LoadDataTable(@"SELECT (SELECT alsofof_code FROM student_t WHERE stu_code = student.stu_code AND asase_code = (SELECT MAX(asase_code) FROM student_t)) AS alsofof_code FROM student where stu_code = " + StudentCode, false, MCfrsan.ConnectionStringdataschool());

            foreach (DataRow row in SafTbl.Rows)
            {
                if (row["alsofof_code"].ToString() == dt.Rows[0][0].ToString())
                {
                    e.Value = row["alsofof_name"].ToString();
                    break;
                }
            }

        }
    }
 /// <summary>
 /// Calcula el total de los Productos
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void GVListaProductos_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridViewColumnDataEventArgs e)
 {
     if (e.Column.FieldName == "Total")
     {
         decimal price = (decimal)e.GetListSourceFieldValue("Costo");
         int quantity = Convert.ToInt32(e.GetListSourceFieldValue("Cantidad"));
         e.Value = price * quantity;
     }
     if (e.Column.FieldName == "IVA")
     {
         e.Value = "IVA 16 %";
     }
 }