コード例 #1
0
        /*
         * public DataTable SelectAll(worksheetdetails objworksheetdetails)
         * {
         *  DataSet ds = new DataSet();
         *  SqlDataAdapter da;
         *  try
         *  {
         *      SqlCommand cmd = new SqlCommand();
         *      cmd.CommandText = "worksheetdetails_SelectAll";
         *      cmd.CommandType = CommandType.StoredProcedure;
         *      cmd.Connection = ConnectionString;
         *
         *      ConnectionString.Open();
         *      da = new SqlDataAdapter(cmd);
         *      da.Fill(ds);
         *  }
         *  catch (Exception ex)
         *  {
         *      ////ErrHandler.writeError(ex.Message, ex.StackTrace);
         *      return null;
         *  }
         *  finally
         *  {
         *      ConnectionString.Close();
         *  }
         *  return ds.Tables[0];
         * }
         * public worksheetdetails SelectById(Int64 id)
         * {
         *  SqlDataAdapter da;
         *  DataSet ds = new DataSet();
         *  worksheetdetails objworksheetdetails = new worksheetdetails();
         *  try
         *  {
         *      SqlCommand cmd = new SqlCommand();
         *      cmd.CommandText = "worksheetdetails_SelectById";
         *      cmd.CommandType = CommandType.StoredProcedure;
         *      cmd.Connection = ConnectionString;
         *      cmd.Parameters.AddWithValue("@PurchaseOrderId", id);
         *      ConnectionString.Open();
         *      da = new SqlDataAdapter(cmd);
         *      da.Fill(ds);
         *
         *      if (ds != null)
         *      {
         *          if (ds.Tables.Count > 0)
         *          {
         *              if (ds.Tables[0] != null)
         *              {
         *                  if (ds.Tables[0].Rows.Count > 0)
         *                  {
         *
         *                      //PurchaseOrderId, VendorId, isdeleted, OrderDate
         *                      objworksheetdetails.worksheetdetailsId = Convert.ToInt64(ds.Tables[0].Rows[0]["worksheetdetailsId"]);
         *
         *                      objworksheetdetails.PurchaseOrderId = Convert.ToInt64(ds.Tables[0].Rows[0]["PurchaseOrderId"]);
         *                      objworksheetdetails.ProdId = Convert.ToInt64(ds.Tables[0].Rows[0]["ProdId"]);
         *                      objworksheetdetails.CategoryId = Convert.ToInt64(ds.Tables[0].Rows[0]["CategoryId"]);
         *                      objworksheetdetails.isdeleted = string.IsNullOrEmpty(ds.Tables[0].Rows[0]["isdeleted"].ToString()) ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["isdeleted"]);
         *                      objworksheetdetails.Quantity1 = Convert.ToInt64(ds.Tables[0].Rows[0]["Quantity1"]);
         *                      objworksheetdetails.Quantity = Convert.ToInt64(ds.Tables[0].Rows[0]["Quantity"]);
         *
         *
         *
         *
         *
         *                  }
         *              }
         *          }
         *      }
         *  }
         *  catch (Exception ex)
         *  {
         *      ////ErrHandler.writeError(ex.Message, ex.StackTrace);
         *      return null;
         *  }
         *  finally
         *  {
         *      ConnectionString.Close();
         *  }
         *  return objworksheetdetails;
         * }
         */
        #endregion


        public Int64 Insert(worksheetdetails objworksheetdetails)
        {
            Int64 result = 0;

            try
            {
                SqlCommand cmd = new SqlCommand
                {
                    CommandText = "worksheetdetails_Insert",
                    CommandType = CommandType.StoredProcedure,
                    Connection  = ConnectionString
                };

                SqlParameter param = new SqlParameter
                {
                    ParameterName = "@id",
                    Value         = objworksheetdetails.Id,
                    SqlDbType     = SqlDbType.BigInt,
                    Direction     = ParameterDirection.InputOutput
                };
                cmd.Parameters.Add(param);

                //id,worksheetid,particularsid,employeeid,quantity,workdate,remark

                //cmd.Parameters.AddWithValue("@id", objworksheetdetails.Id);
                cmd.Parameters.AddWithValue("@worksheetid", objworksheetdetails.Worksheetid);
                cmd.Parameters.AddWithValue("@particularsid", objworksheetdetails.Particularsid);
                cmd.Parameters.AddWithValue("@employeeid", objworksheetdetails.Employeeid);
                cmd.Parameters.AddWithValue("@quantity", objworksheetdetails.Quantity);
                cmd.Parameters.AddWithValue("@wages", objworksheetdetails.Wages);
                cmd.Parameters.AddWithValue("@workdate", objworksheetdetails.Workdate);
                cmd.Parameters.AddWithValue("@remark", objworksheetdetails.Remark);

                //cmd.Parameters.AddWithValue("@isdeleted", objworksheetdetails.isdeleted);
                //cmd.Parameters.AddWithValue("@Quantity1", objworksheetdetails.Quantity1);



                ConnectionString.Open();
                cmd.ExecuteNonQuery();
                result = Convert.ToInt64(param.Value);
            }
            catch (Exception ex)
            {
                //ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(result);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(result);
        }
コード例 #2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Int64     Result = 0, Result1 = 0;
        DataTable dtProduct = new DataTable();

        //Response.Write(hf1.Value);

        String valuesColor = hfcolorid.Value, valuesSize = hfsizeid.Value;


        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["cnstring"].ConnectionString);
        //id,productid,sizeid,colorid,createdby,createddate,isdeleted
        worksheetmaster objworksheetmaster = new worksheetmaster();

        objworksheetmaster.Productid = Convert.ToInt64(ddlArticle.SelectedValue.ToString());
        //objworksheetmaster.Sizeid = Convert.ToInt64(ddlSize.SelectedValue.ToString());
        //objworksheetmaster.Colorid = Convert.ToInt64(ddlColor.SelectedValue.ToString());
        objworksheetmaster.Colorid     = valuesColor;
        objworksheetmaster.Sizeid      = valuesSize;
        objworksheetmaster.Createdby   = Convert.ToInt64(createdby);
        objworksheetmaster.Createddate = Convert.ToDateTime(txtWorkDate.Text.ToString());

        //PurchaseOrderHeader objcategory = new PurchaseOrderHeader();
        //objcategory.PONo = pono;
        //objcategory.VendorId = Int64.Parse(ddlVendor.SelectedValue);

        //objcategory.isdeleted = false;

        if (Request.QueryString["id"] != null)
        {
            objworksheetmaster.Id = Convert.ToInt64(ocommon.Decrypt(Request.QueryString["id"].ToString(), true));
            Result = (new Cls_worksheetmaster_b().Update(objworksheetmaster));
            if (Result > 0)
            {
                Response.Redirect(Page.ResolveUrl("~/manageworksheets.aspx?mode=u"));
            }
            else
            {
            }
        }
        else
        {
            Result = (new Cls_worksheetmaster_b().Insert(objworksheetmaster));
            if (Result > 0)
            {
                con.Open();
                if (ViewState["Products"] != null)
                {
                    dtProduct = (DataTable)ViewState["Products"];
                }
                worksheetdetails objPod = new worksheetdetails();
                foreach (DataRow row in dtProduct.Rows)
                {
                    //id,worksheetid,particularsid,employeeid,workdate,quantity,remark

                    objPod.Worksheetid   = Result;
                    objPod.Particularsid = Convert.ToInt64(row["operationid"]);
                    objPod.Employeeid    = Convert.ToInt64(row["employeeid"]);
                    objPod.Quantity      = Convert.ToInt64(row["quantity"]);
                    objPod.Wages         = Convert.ToDouble(row["wages"]);
                    objPod.Workdate      = Convert.ToDateTime(row["date"]);
                    objPod.Remark        = Convert.ToString(row["remark"]);

                    Result1 = (new Cls_worksheetdetails_b().Insert(objPod));

                    //if (Result1 > 0)
                    // flag = true;
                }

                con.Close();
                Response.Redirect(Page.ResolveUrl("~/manageworksheets.aspx?mode=i"));
            }
            else
            {
            }
        }
    }