コード例 #1
0
ファイル: EquiptmentSET.aspx.cs プロジェクト: hmooza/T-REC
        private void Save()
        {
            Equipment_SET Equipment_SETone = new Equipment_SET();
            List <Equipment_SET_detail> lstEquipment_SET_detail = null;

            //GridView grid_Detail = grid_Detail;
            if (this.grid_Detail != null && this.grid_Detail.Rows.Count > 0)
            {
                lstEquipment_SET_detail = new List <Equipment_SET_detail>();

                foreach (GridViewRow item in grid_Detail.Rows)
                {
                    Equipment_SET_detail en = new Equipment_SET_detail();

                    en.Equip_ID = Convert.ToInt32(item.Cells[Enum_grid_Detail.ID.GetHashCode()].Text);         //ID
                    en.cost     = Convert.ToDecimal(item.Cells[Enum_grid_Detail.CostRent.GetHashCode()].Text); //CostRent

                    lstEquipment_SET_detail.Add(en);
                }
            }

            if (VSEnum_Mode == Enum_Mode.Add)
            {
                Equipment_SETone.Price       = Convert.ToDecimal(this.txtPrice.Text);
                Equipment_SETone.SETName     = this.txtSetName.Text;
                Equipment_SETone.Description = this.txtDescription.Text;
            }
            else if (VSEnum_Mode == Enum_Mode.Edit)
            {
                //Equipment_SET[] Equipment_SETs = null;
                //ClassSet.GetDate_Equipment_SET(out Equipment_SETs, VSSet_Id);
                lstEquipment_SET_detail.ToList().ForEach(x => x.SET_ID = VSSet_Id.Value);
                //SSEquipments
            }
            else if (VSEnum_Mode == Enum_Mode.Delete)
            {
            }

            //Call Save
            int?SET_ID = ClassSet.SetData_Equipment(Equipment_SETone, lstEquipment_SET_detail, VSEnum_Mode.GetHashCode());

            if (SET_ID != null)
            {
                initial(SET_ID);

                string message = "บันทึกเรียบร้อยแล้ว";
                MessageShow(message);
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "ToggleScript", "Alert(" + message + ")", true);
            }
        }