Esempio n. 1
0
        protected void bDeleteD_Click(object sender, ImageClickEventArgs e)
        {
            lock (Database.lockObjectDB)
            {
                int id = Convert.ToInt32(gvPurchDogs.DataKeys[gvPurchDogs.SelectedIndex].Values["id"]);
                if (!CheckProducts(id))
                {
                    return;
                }
                DelProducts(id);
                SqlCommand sqCom = new SqlCommand();
                object     obj   = null;
                sqCom.CommandText = "delete from Products_PurchDogs where id_dog=@id";
                sqCom.Parameters.Add("@id", SqlDbType.Int).Value = id;
                Database.ExecuteNonQuery(sqCom, null);
                sqCom.CommandText = "select number_dog from PurchDogs where id=@id";
                res = Database.ExecuteScalar(sqCom, ref obj, null);
                sqCom.CommandText = "delete from PurchDogs where id=@id";
                Database.ExecuteNonQuery(sqCom, null);
                Database.Log(sc.UserGuid(User.Identity.Name), String.Format("Удален договор на закупку {0}", (obj == null) ? "" : (string)obj), null);

                Refr(0, false);
                lbInform.Text = "";
            }
        }
Esempio n. 2
0
 protected void bDeleteCard_Click(object sender, ImageClickEventArgs e)
 {
     lock (Database.lockObjectDB)
     {
         string     pan = "";
         CheckBox   cb;
         SqlCommand comm = new SqlCommand();
         CheckBox   cbA  = (CheckBox)gvCard.HeaderRow.FindControl("cbSelectAll");
         if (cbA.Checked)
         {
             string str = lbSearch.Text.Trim();
             if (str.Length > 0)
             {
                 str += " and " + branchSearch;
             }
             else
             {
                 str += " where " + branchSearch;
             }
             str += " and (id_stat=1 or id_stat=2)";
             comm.CommandText = "delete from Cards " + str;
             Database.ExecuteNonQuery(comm, null);
         }
         else
         {
             comm.Parameters.Add("@id", SqlDbType.Int);
             foreach (GridViewRow gvr in gvCard.Rows)
             {
                 cb = (CheckBox)gvr.FindControl("cbSelect");
                 if (cb.Checked && (int)gvCard.DataKeys[gvr.RowIndex].Values["id_stat"] == 1)
                 {
                     comm.Parameters["@id"].Value = (int)gvCard.DataKeys[gvr.RowIndex].Values["id"];
                     pan = gvCard.DataKeys[gvr.RowIndex].Values["pan"].ToString();
                     comm.CommandText = "delete from Cards where id=@id";
                     Database.ExecuteNonQuery(comm, null);
                     Database.Log(sc.UserGuid(User.Identity.Name), String.Format("Удалена карта {0} в статусе обработка", pan), null);
                 }
             }
         }
         Refr(false);
     }
 }