Exemplo n.º 1
0
        protected void GrDelete(object sender, CommandEventArgs e)
        {
            int nPageNumber             = int.Parse(txtPageNumber.Text);
            int nPageSize               = int.Parse(txtPageSize.Text);
            SessionUserLogin nUserLogin = (SessionUserLogin)Session["UserLogin"];

            nUserLogin.CheckRole("CU0002");
            //if (!nUserLogin.Role.Del)W
            //{
            //    Response.Write("<script >alert('Bạn không có quyền xóa danh mục này!')</script>");
            //}
            //else
            {
                try
                {
                    int mKey = int.Parse(e.CommandArgument.ToString());
                    ProcessPlantDetail_Info info = new ProcessPlantDetail_Info(mKey);
                    //if ((DateTime.Now - info.CreatedDateTime).TotalDays > 7)
                    //{
                    //    Response.Write("<script >alert('Dữ liệu đã quá 7 ngày, không được phép xóa!')</script>");
                    //}
                    //else
                    {
                        info.Delete();
                        DataTable nTable = ProcessPlantDetail_Data.GetList(nPageSize, nPageNumber, txtSearch.Text, _key);
                        if (nTable.Rows.Count == 0)
                        {
                            nTable.Rows.Add(0, 0, "", 0);
                        }
                        GV_List.DataSource = nTable;
                        GV_List.DataBind();
                        LoadPages();
                    }
                }
                catch
                {
                    Response.Write("<script >alert('Có lỗi gì đó vui lòng thử lại!')</script>");
                }
            }
        }
Exemplo n.º 2
0
        protected void SaveInfo()
        {
            switch (typekey)
            {
            case 1:
                if (txtAction.Text == "" || txtReason.Text == "" || txtSolution.Text == "" || txtDescription.Text == "" || txtDateNum.Text == "")
                {
                    Err.Text = "Vui lòng nhập đầy đủ thông tin";
                    return;
                }

                break;

            case 2:
                if (txtDateBuy.Text == "" || txtDateOfManufacture.Text == "" || txtDateSowing.Text == "" || txtCompany.Text == "" || txtEndNum.Text == "")
                {
                    Err.Text = "Vui lòng nhập đầy đủ thông tin";
                    return;
                }

                break;

            case 3:
                if (txtDateNum2.Text == "" || txtParcel2.Text == "" || txtHowtouse.Text == "" || txtFormulaUsed.Text == "")    // || txtQuantity.Text == "" || txtReason.Text == "" || txtEndNum.Text == "")
                {
                    Err.Text = "Vui lòng nhập đầy đủ thông tin";
                    return;
                }

                break;

            case 4:
                if (txtDatetime.Text == "" || txtArea3.Text == "" || txtPestName.Text == "" || txtSolution2.Text == "" || txtDose.Text == "" || txtGT.Text == "")    // txtReason.Text == "" || txtEndNum.Text == "")
                {
                    Err.Text = "Vui lòng nhập đầy đủ thông tin";
                    return;
                }

                break;
            }
            ProcessPlantDetail_Info minfo = new ProcessPlantDetail_Info(mainkey.ToInt());
            int newkey = 0;

            if (mainkey == "0")
            {
                minfo.ProcessPlantDetai_Type = DDLType.SelectedValue.ToInt();
                minfo.Description            = txtDescription.Text;
                minfo.DateNum         = txtDateNum.Text.ToInt();
                minfo.ProcessPlantKey = Session["ProcessPlantKey"].ToInt();
                newkey = minfo.Create().ToInt();
            }

            else
            {
                minfo.ProcessPlantDetai_Type = DDLType.SelectedValue.ToInt();
                minfo.Description            = txtDescription.Text;
                if (txtDateNum.Text != "")
                {
                    minfo.DateNum = txtDateNum.Text.ToInt();
                }
                else
                {
                    if (txtDateNum2.Text != "")
                    {
                        minfo.DateNum = txtDateNum2.Text.ToInt();
                    }
                    else
                    {
                        if (txtDateOfManufacture.Text != "")
                        {
                            minfo.DateNum = txtDateOfManufacture.Text.ToInt();
                        }
                        else
                        {
                            minfo.DateNum = txtDatetime.Text.ToInt();
                        }
                    }
                }
                minfo.Update();
                newkey = minfo.ProcessPlantDetailKey;
            }
            int SeedKey = LoadDataToToolboxWeb.GetID("Select SeedsKey from PUL_ProcessPlant WHERE ProcessPlantKey = " + LoadDataToToolboxWeb.GetID("Select ProcessPlantKey from PUL_ProcessPlantDetail where ProcessPlantDetailKey = " + newkey.ToString()));

            switch (typekey)
            {
            case 1:
                if (txtAction.Text == "" || txtReason.Text == "" || txtSolution.Text == "" || txtDescription.Text == "" || txtDateNum.Text == "")
                {
                    Err.Text = "Vui lòng nhập đầy đủ thông tin";
                    return;
                }
                Process_LandUse_Info info = new Process_LandUse_Info(oderkey);
                info.Action   = txtAction.Text;
                info.Reason   = txtReason.Text;
                info.Solution = txtSolution.Text;
                info.Note     = txtDescription.Text;
                info.ProcessPlantDetailKey = newkey;
                info.SeedKey      = SeedKey;
                info.Datetime_Num = txtDateNum.Text.ToInt();
                info.Save();
                break;

            case 2:
                if (txtDateBuy.Text == "" || txtDateOfManufacture.Text == "" || txtDateSowing.Text == "" || txtCompany.Text == "" || txtEndNum.Text == "")
                {
                    Err.Text = "Vui lòng nhập đầy đủ thông tin";
                    return;
                }
                Process_SeedProces_Info info2 = new Process_SeedProces_Info(oderkey);
                info2.DateBuy_Num           = txtDateBuy.Text.ToInt();
                info2.DateOfManufacture_Num = txtDateOfManufacture.Text.ToInt();
                info2.DateSowing_Num        = txtDateSowing.Text.ToInt();
                info2.CompanyName           = txtCompany.Text;
                info2.Parcel                = ""; //txtParcel.Text;
                info2.Area                  = 0;  //txtArea.Text.ToInt();
                info2.AreaUnit              = 0;  //DDLAreaUnit.SelectedValue.ToInt();
                info2.Quantity              = 0;  //txtQuantity.Text.ToInt();
                info2.QuantityUnit          = 0;  //DDLQuantityUnit.SelectedValue.ToInt();
                info2.ProcessPlantDetailKey = newkey;
                info2.SeedsKey              = SeedKey.ToString();
                info2.Reasons               = txtReason.Text;
                info2.EndTime_Num           = txtEndNum.Text.ToInt();
                info2.Save();
                break;

            case 3:
                if (txtDateNum2.Text == "" || txtParcel2.Text == "" || txtHowtouse.Text == "" || txtFormulaUsed.Text == "")    // || txtQuantity.Text == "" || txtReason.Text == "" || txtEndNum.Text == "")
                {
                    Err.Text = "Vui lòng nhập đầy đủ thông tin";
                    return;
                }
                Process_FertilizerUse_Info info3 = new Process_FertilizerUse_Info(oderkey);
                info3.DateTimeUse_Num       = txtDateNum2.Text.ToInt();
                info3.Parcel                = txtParcel2.Text;
                info3.Area                  = txtArea2.Text;
                info3.Howtouse              = txtHowtouse.Text;
                info3.CooperativeKey        = DDLEquipment.SelectedValue.ToInt();
                info3.FertilizerKey         = DDLFertilizer.SelectedValue.ToInt();
                info3.FormulaUsed           = float.Parse(txtFormulaUsed.Text);
                info3.UnitKey               = DDLUnit.SelectedValue.ToInt();
                info3.Quantity              = "0"; //txtQuantity2.Text;
                info3.QuarantinePeriod      = "0"; //txtQuarantinePeriod.Text;
                info3.SeedKey               = SeedKey;
                info3.ProcessPlantDetailKey = newkey;
                info3.Save();
                break;

            case 4:
                if (txtDatetime.Text == "" || txtArea3.Text == "" || txtPestName.Text == "" || txtSolution2.Text == "" || txtDose.Text == "" || txtGT.Text == "")    // txtReason.Text == "" || txtEndNum.Text == "")
                {
                    Err.Text = "Vui lòng nhập đầy đủ thông tin";
                    return;
                }
                Process_PesticideUse_Info info4 = new Process_PesticideUse_Info(oderkey);
                info4.DateTimeUse_Num       = txtDatetime.Text.ToInt();
                info4.Area                  = txtArea3.Text;
                info4.PestName              = txtPestName.Text;
                info4.Solution              = txtSolution2.Text;
                info4.EquipmentKey          = DDLEquip.SelectedValue.ToInt();
                info4.PesticideKey          = DDLPesticide.SelectedValue.ToInt();
                info4.Dose                  = float.Parse(txtDose.Text);
                info4.Dosage                = "Chưa có dữ liệu";//txtDosage.Text;
                info4.QuarantinePeriod      = txtGT.Text;
                info4.SeedKey               = SeedKey;
                info4.ProcessPlantDetailKey = newkey;
                info4.UnitKey               = DDLU.SelectedValue.ToInt();
                info4.Save();
                break;
            }
            CloseForm();
        }
Exemplo n.º 3
0
        protected void LoadInfo(int Key)
        {
            ProcessPlantDetail_Info minfo = new ProcessPlantDetail_Info(mainkey.ToInt());

            DDLType.SelectedValue = minfo.ProcessPlantDetai_Type.ToString();
            txtDescription.Text   = minfo.Description;
            switch (Key)
            {
            case 1:
            {
                Process_LandUse_Info info = new Process_LandUse_Info(oderkey);
                txtAction.Text   = info.Action;
                txtReason.Text   = info.Reason;
                txtSolution.Text = info.Solution;
                txtDateNum.Text  = info.Datetime_Num.ToString();
                break;
            }

            case 2:
            {
                Process_SeedProces_Info info = new Process_SeedProces_Info(oderkey);
                txtDateBuy.Text           = info.DateBuy_Num.ToString();
                txtDateOfManufacture.Text = info.DateOfManufacture_Num.ToString();
                txtDateSowing.Text        = info.DateSowing_Num.ToString();
                txtCompany.Text           = info.CompanyName;
                //txtParcel.Text = info.Parcel;
                //txtArea.Text = info.Area.ToString();
                // DDLAreaUnit.SelectedValue = info.AreaUnit.ToString();
                // txtQuantity.Text = info.Quantity.ToString();
                // DDLQuantityUnit.SelectedValue = info.QuantityUnit.ToString();
                txtReason.Text = info.Reasons;
                txtEndNum.Text = info.EndTime_Num.ToString();
                break;
            }

            case 3:
                Process_FertilizerUse_Info info3 = new Process_FertilizerUse_Info(oderkey);
                txtDateNum2.Text = info3.DateTimeUse_Num.ToString();
                txtParcel2.Text  = info3.Parcel;
                txtArea2.Text    = info3.Area;
                txtHowtouse.Text = info3.Howtouse;

                DDLFertilizer.SelectedValue = info3.FertilizerKey.ToString();
                txtFormulaUsed.Text         = info3.FormulaUsed.ToString();
                if (oderkey != 0)
                {
                    DDLUnit.SelectedValue      = info3.UnitKey.ToString();
                    DDLEquipment.SelectedValue = info3.CooperativeKey.ToString();
                }
                else
                {
                    DDLUnit.SelectedValue      = "3";
                    DDLEquipment.SelectedValue = "5";
                }
                //txtQuantity2.Text = info3.Quantity;
                //txtQuarantinePeriod.Text = info3.QuarantinePeriod;
                break;

            case 4:
                Process_PesticideUse_Info info4 = new Process_PesticideUse_Info(oderkey);
                txtDatetime.Text           = info4.DateTimeUse_Num.ToString();
                txtArea3.Text              = info4.Area;
                txtPestName.Text           = info4.PestName;
                txtSolution2.Text          = info4.Solution;
                DDLEquip.SelectedValue     = info4.EquipmentKey.ToString();
                DDLPesticide.SelectedValue = info4.PesticideKey.ToString();
                txtDose.Text       = info4.Dose.ToString();
                DDLU.SelectedValue = info4.UnitKey.ToString();
                //txtDosage.Text = info4.Dosage;
                txtGT.Text = info4.QuarantinePeriod;
                break;
            }
        }