Example #1
0
        public void Save()
        {
            try
            {
                if (!AllowSave)
                {
                    return;
                }
                List <DynamicValue> lstValues = new List <DynamicValue>();
                if (dr != null)
                {
                    DynamicValue objVal = null;


                    if (Utility.Int32Dbnull(dr["idValue"], -1) > 0)
                    {
                        objVal       = DynamicValue.FetchByID(Utility.Int32Dbnull(dr["idValue"], -1));
                        objVal.IsNew = false;
                        objVal.MarkOld();
                    }
                    else
                    {
                        objVal       = new DynamicValue();
                        objVal.IsNew = true;
                    }

                    objVal.Id               = Utility.Int32Dbnull(dr["idValue"], -1);
                    objVal.Ma               = Utility.sDbnull(dr[DynamicField.Columns.Ma], "-1");
                    objVal.Giatri           = Utility.DoTrim(txtValue.Text);
                    objVal.Rtf              = txtValue.Rtf;
                    objVal.ImageId          = -1;
                    objVal.IdChidinhchitiet = Utility.Int32Dbnull(dr[DynamicValue.Columns.IdChidinhchitiet], -1);

                    lstValues.Add(objVal);
                    clsHinhanh.UpdateDynamicValues(lstValues);
                    dr["idValue"] = objVal.Id;
                    isSaved       = true;
                }
            }
            catch (Exception ex)
            {
            }
        }
        //private void cmdSave_Click(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        List<DynamicField> lstFields = new List<DynamicField>();
        //        List<DynamicValue> lstValues = new List<DynamicValue>();
        //        foreach (GridEXRow _row in grdList.GetDataRows())
        //        {
        //            DynamicField obj = null;
        //            DynamicValue objVal = null;

        //            if (Utility.Int32Dbnull(_row.Cells[DynamicField.Columns.Id].Value, -1) > 0)
        //            {
        //                obj = DynamicField.FetchByID(Utility.Int32Dbnull(_row.Cells[DynamicField.Columns.Id].Value, -1));
        //                obj.IsNew = false;
        //                obj.MarkOld();
        //            }
        //            else
        //            {
        //                obj = new DynamicField();
        //                obj.IsNew = true;
        //            }

        //            if (Utility.Int32Dbnull(_row.Cells["idValue"].Value, -1) > 0)
        //            {
        //                objVal = DynamicValue.FetchByID(Utility.Int32Dbnull(_row.Cells["idValue"].Value, -1));
        //                objVal.IsNew = false;
        //                objVal.MarkOld();
        //            }
        //            else
        //            {
        //                objVal = new DynamicValue();
        //                objVal.IsNew = true;
        //            }


        //            obj.Id = Utility.Int32Dbnull(_row.Cells[DynamicField.Columns.Id].Value, -1);
        //            obj.Ma = Utility.sDbnull(_row.Cells[DynamicField.Columns.Ma].Value, "-1");
        //            obj.Bodypart = objDichvuchitiet.Bodypart;
        //            obj.Viewposition = objDichvuchitiet.ViewPosition;

        //            objVal.Id = Utility.Int32Dbnull(_row.Cells["idValue"].Value, -1);
        //            objVal.Ma = Utility.sDbnull(_row.Cells[DynamicField.Columns.Ma].Value, "-1");
        //            obj.Mota = Utility.sDbnull(_row.Cells[DynamicField.Columns.Mota].Value, "-1");
        //            objVal.Giatri = Utility.sDbnull(_row.Cells[DynamicValue.Columns.Giatri].Value, "-1");
        //            objVal.ImageId = ImageID;
        //            objVal.IdChidinhchitiet = Id_chidinhchitiet;
        //            lstFields.Add(obj);
        //            lstValues.Add(objVal);
        //        }
        //        ActionResult _actionResult = UpdateDynamicValues(lstFields, lstValues);
        //        if (_actionResult == ActionResult.Success)
        //        {
        //            this.Close();
        //        }

        //    }
        //    catch (Exception ex)
        //    {
        //    }
        //}
        private void cmdSave_Click(object sender, EventArgs e)
        {
            try
            {
                List <DynamicValue> lstValues = new List <DynamicValue>();
                foreach (GridEXRow _row in grdList.GetDataRows())
                {
                    DynamicValue objVal = null;


                    if (Utility.Int32Dbnull(_row.Cells["idValue"].Value, -1) > 0)
                    {
                        objVal       = DynamicValue.FetchByID(Utility.Int32Dbnull(_row.Cells["idValue"].Value, -1));
                        objVal.IsNew = false;
                        objVal.MarkOld();
                    }
                    else
                    {
                        objVal       = new DynamicValue();
                        objVal.IsNew = true;
                    }

                    objVal.Id               = Utility.Int32Dbnull(_row.Cells["idValue"].Value, -1);
                    objVal.Ma               = Utility.sDbnull(_row.Cells[DynamicField.Columns.Ma].Value, "-1");
                    objVal.Giatri           = Utility.sDbnull(_row.Cells[DynamicValue.Columns.Giatri].Value, "-1");
                    objVal.ImageId          = ImageID;
                    objVal.IdChidinhchitiet = Id_chidinhchitiet;

                    lstValues.Add(objVal);
                }
                ActionResult _actionResult = UpdateDynamicValues(lstValues);
                if (_actionResult == ActionResult.Success)
                {
                    this.Close();
                }
            }
            catch (Exception ex)
            {
            }
        }