Exemple #1
0
        public static void Update(tsa_ComprobanteDetalleEstadoItemsDataset.tsa_ComprobanteDetalleEstadoItemsDataTable dataTable, SqlTransaction trx)
        {
            SqlDataAdapter adapter = new SqlDataAdapter();

            adapter.TableMappings.AddRange(
                new System.Data.Common.DataTableMapping[] {
                new System.Data.Common.DataTableMapping("Table", "tsa_ComprobanteDetalleEstadoItems",
                                                        new System.Data.Common.DataColumnMapping[] {
                    new System.Data.Common.DataColumnMapping("IdComprobante", "IdComprobante"),
                    new System.Data.Common.DataColumnMapping("Ordinal", "Ordinal"),
                    new System.Data.Common.DataColumnMapping("Cantidad", "Cantidad"),
                    new System.Data.Common.DataColumnMapping("Fecha", "Fecha"),
                    new System.Data.Common.DataColumnMapping("IdEstado", "IdEstado"),
                    new System.Data.Common.DataColumnMapping("Observaciones", "Observaciones"),
                    new System.Data.Common.DataColumnMapping("IdEmpresa", "IdEmpresa"),
                    new System.Data.Common.DataColumnMapping("IdSucursal", "IdSucursal"),
                    new System.Data.Common.DataColumnMapping("FechaCreacion", "FechaCreacion"),
                    new System.Data.Common.DataColumnMapping("IdConexionCreacion", "IdConexionCreacion"),
                    new System.Data.Common.DataColumnMapping("UltimaModificacion", "UltimaModificacion"),
                    new System.Data.Common.DataColumnMapping("IdConexionUltimaModificacion", "IdConexionUltimaModificacion"),
                    new System.Data.Common.DataColumnMapping("IdReservado", "IdReservado"),
                    new System.Data.Common.DataColumnMapping("RowId", "RowId")
                }
                                                        )
            }
                );

            SqlCommand sqlCommandUpdate = new SqlCommand("Pr_tsa_ComprobanteDetalleEstadoItems_Update", trx.Connection);

            sqlCommandUpdate.Transaction = trx;
            sqlCommandUpdate.CommandType = CommandType.StoredProcedure;
            sqlCommandUpdate.Parameters.Add(new SqlParameter("@IdComprobante", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdComprobante", DataRowVersion.Current, null));
            sqlCommandUpdate.Parameters.Add(new SqlParameter("@Ordinal", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Ordinal", DataRowVersion.Current, null));
            sqlCommandUpdate.Parameters.Add(new SqlParameter("@Cantidad", SqlDbType.Decimal, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Cantidad", DataRowVersion.Current, null));
            sqlCommandUpdate.Parameters.Add(new SqlParameter("@Fecha", SqlDbType.DateTime, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Fecha", DataRowVersion.Current, null));
            sqlCommandUpdate.Parameters.Add(new SqlParameter("@IdEstado", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdEstado", DataRowVersion.Current, null));
            sqlCommandUpdate.Parameters.Add(new SqlParameter("@Observaciones", SqlDbType.VarChar, 500, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Observaciones", DataRowVersion.Current, null));
            sqlCommandUpdate.Parameters.Add(new SqlParameter("@IdEmpresa", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdEmpresa", DataRowVersion.Current, null));
            sqlCommandUpdate.Parameters.Add(new SqlParameter("@IdSucursal", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdSucursal", DataRowVersion.Current, null));
            sqlCommandUpdate.Parameters.Add(new SqlParameter("@UltimaModificacion", SqlDbType.Timestamp, 8, ParameterDirection.InputOutput, false, ((System.Byte)(0)), ((System.Byte)(0)), "UltimaModificacion", DataRowVersion.Current, null));
            sqlCommandUpdate.Parameters.Add(new SqlParameter("@IdConexionUltimaModificacion", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdConexionUltimaModificacion", DataRowVersion.Current, null));
            sqlCommandUpdate.Parameters.Add(new SqlParameter("@IdReservado", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdReservado", DataRowVersion.Current, null));
            sqlCommandUpdate.Parameters.Add(new SqlParameter("@OldIdComprobante", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdComprobante", DataRowVersion.Original, null));
            sqlCommandUpdate.Parameters.Add(new SqlParameter("@OldOrdinal", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Ordinal", DataRowVersion.Original, null));
            sqlCommandUpdate.Parameters.Add(new SqlParameter("@OldFecha", SqlDbType.DateTime, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Fecha", DataRowVersion.Original, null));
            sqlCommandUpdate.Parameters.Add(new SqlParameter("@OldIdEstado", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdEstado", DataRowVersion.Original, null));

            SqlCommand sqlCommandDelete = new SqlCommand("Pr_tsa_ComprobanteDetalleEstadoItems_Delete", trx.Connection);

            sqlCommandDelete.Transaction = trx;
            sqlCommandDelete.CommandType = CommandType.StoredProcedure;
            sqlCommandDelete.Parameters.Add(new SqlParameter("@IdComprobante", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdComprobante", DataRowVersion.Original, null));
            sqlCommandDelete.Parameters.Add(new SqlParameter("@Ordinal", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Ordinal", DataRowVersion.Original, null));
            sqlCommandDelete.Parameters.Add(new SqlParameter("@Fecha", SqlDbType.DateTime, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Fecha", DataRowVersion.Original, null));
            sqlCommandDelete.Parameters.Add(new SqlParameter("@IdEstado", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdEstado", DataRowVersion.Original, null));
            sqlCommandDelete.Parameters.Add(new SqlParameter("@UltimaModificacion", SqlDbType.Timestamp, 8, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "UltimaModificacion", DataRowVersion.Original, null));

            SqlCommand sqlCommandInsert = new SqlCommand("Pr_tsa_ComprobanteDetalleEstadoItems_Insert", trx.Connection);

            sqlCommandInsert.Transaction = trx;
            sqlCommandInsert.CommandType = CommandType.StoredProcedure;
            sqlCommandInsert.Parameters.Add(new SqlParameter("@IdComprobante", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdComprobante", DataRowVersion.Current, null));
            sqlCommandInsert.Parameters.Add(new SqlParameter("@Ordinal", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Ordinal", DataRowVersion.Current, null));
            sqlCommandInsert.Parameters.Add(new SqlParameter("@Cantidad", SqlDbType.Decimal, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Cantidad", DataRowVersion.Current, null));
            sqlCommandInsert.Parameters.Add(new SqlParameter("@Fecha", SqlDbType.DateTime, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Fecha", DataRowVersion.Current, null));
            sqlCommandInsert.Parameters.Add(new SqlParameter("@IdEstado", SqlDbType.VarChar, 20, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdEstado", DataRowVersion.Current, null));
            sqlCommandInsert.Parameters.Add(new SqlParameter("@Observaciones", SqlDbType.VarChar, 500, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Observaciones", DataRowVersion.Current, null));
            sqlCommandInsert.Parameters.Add(new SqlParameter("@IdEmpresa", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdEmpresa", DataRowVersion.Current, null));
            sqlCommandInsert.Parameters.Add(new SqlParameter("@IdSucursal", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdSucursal", DataRowVersion.Current, null));
            sqlCommandInsert.Parameters.Add(new SqlParameter("@FechaCreacion", SqlDbType.DateTime, 0, ParameterDirection.InputOutput, false, ((System.Byte)(0)), ((System.Byte)(0)), "FechaCreacion", DataRowVersion.Current, null));
            sqlCommandInsert.Parameters.Add(new SqlParameter("@IdConexionCreacion", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdConexionCreacion", DataRowVersion.Current, null));
            sqlCommandInsert.Parameters.Add(new SqlParameter("@IdReservado", SqlDbType.BigInt, 0, ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "IdReservado", DataRowVersion.Current, null));

            adapter.UpdateCommand = sqlCommandUpdate;
            adapter.DeleteCommand = sqlCommandDelete;
            adapter.InsertCommand = sqlCommandInsert;
            adapter.Update(dataTable);
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            mydate                    = dtpAdd.Value;
            sqlFormattedDate          = mydate.ToString("yyyy-MM-dd HH:mm:ss.fff");
            lbGroupName.DataSource    = dsBookings.Tables["Groups"];
            lbGroupName.DisplayMember = "Group Name";
            GroupID                   = (lbGroupName.SelectedItem as DataRowView)["Group Number ID"].ToString();
            GroupName                 = lbGroupName.GetItemText(lbGroupName.SelectedItem);
            RoomID                    = lbRoomID.GetItemText(lbRoomID.SelectedItem);
            Session                   = lbSessions.GetItemText(lbSessions.SelectedItem);
            sqlExists                 = @"SELECT COUNT(*) FROM [Practice Room Booking] WHERE [Room ID] like '" + RoomID + "' AND [Slot ID] like '" + Session + "' AND [Date] = '" + sqlFormattedDate + "'";
            daCount                   = new SqlDataAdapter(sqlExists, cnStr);
            int        groupID = int.Parse(GroupID);
            int        session = int.Parse(Session);
            int        roomID  = int.Parse(RoomID);
            SqlCommand cmd     = new SqlCommand(sqlExists, conn);

            conn.Open();

            Int32 count = Convert.ToInt32(cmd.ExecuteScalar());

            if (count == 0)
            {
                myBooking MyBooking = new myBooking();

                MyBooking.groupID          = groupID;
                MyBooking.slotID           = session;
                MyBooking.roomID           = roomID;
                MyBooking.date             = sqlFormattedDate;
                MyBooking.equipmentRequest = txtEquipRequest.Text.Trim();

                try
                {
                    drBooking = dsBookings.Tables["Practice Room Booking"].NewRow();

                    drBooking["Group ID"]          = MyBooking.groupID;
                    drBooking["Room ID"]           = MyBooking.roomID;
                    drBooking["Date"]              = MyBooking.date;
                    drBooking["Slot ID"]           = MyBooking.slotID;
                    drBooking["Equipment Request"] = MyBooking.equipmentRequest;

                    dsBookings.Tables["Practice Room Booking"].Rows.Add(drBooking);
                    daBookings.Update(dsBookings, "Practice Room Booking");
                    MessageBox.Show("New booking has been added.");
                    dsBookings.Clear();
                    daBookings.Fill(dsBookings, "Practice Room Booking");
                    daGroups.FillSchema(dsBookings, SchemaType.Source, "Groups");
                    daGroups.Fill(dsBookings, "Groups");
                    daRooms.FillSchema(dsBookings, SchemaType.Source, "Rooms");
                    daRooms.Fill(dsBookings, "Rooms");
                    daSession.FillSchema(dsBookings, SchemaType.Source, "Slots");
                    daSession.Fill(dsBookings, "Slots");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error occured.",
                                    MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
                }
            }
            else if (count != 0)
            {
                MessageBox.Show("There is currently a booking in this slot.");
            }
            conn.Close();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            con = new SqlConnection(source);
            con.Open();
            string select1 = "select * from goods";

            sda = new SqlDataAdapter(select1, con);
            sda.Fill(ds, "goods");
            //此处必须新定义一个SqlDataAdapter,否则goods表会多一列customers表的cname(具体原因不清楚)
            SqlDataAdapter sda2 = new SqlDataAdapter("selectgerenxinxi", con);

            sda2.SelectCommand.CommandType = CommandType.StoredProcedure;
            sda2.SelectCommand.Parameters.AddWithValue("@name", yonghuyanzhengjiemian.yonghuname);
            sda2.Fill(ds, "customers");
            foreach (DataRow x in ds.Tables["goods"].Rows)
            {
                if (x["goodsid"].ToString().Trim() == textBox1.Text && Convert.ToInt32(x["storage"]) >= Convert.ToInt32(textBox2.Text))
                {
                    int goodsid = Convert.ToInt32(textBox1.Text);
                    MessageBox.Show("商品编号:" + goodsid.ToString());
                    int customerid = 0;
                    foreach (DataRow y in ds.Tables["customers"].Rows)
                    {
                        if (y["cname"].ToString().Trim() == yonghuyanzhengjiemian.yonghuname)
                        {
                            customerid = Convert.ToInt32(y["customerid"]);
                            break;
                        }
                    }
                    MessageBox.Show("会员编号:" + customerid.ToString());
                    int quantity = Convert.ToInt32(textBox2.Text);
                    MessageBox.Show("订单数量:" + quantity.ToString());
                    int ordersum = quantity * Convert.ToInt32(x["price"]);
                    MessageBox.Show(ordersum.ToString());
                    DateTime orderdate = DateTime.Now;
                    MessageBox.Show(orderdate.ToShortDateString());
                    SqlCommand com = new SqlCommand("insertorders", con);
                    com.CommandType = CommandType.StoredProcedure;
                    com.Parameters.AddWithValue("@goodsid", goodsid);
                    com.Parameters.AddWithValue("@customerid", customerid);
                    com.Parameters.AddWithValue("@quantity", quantity);
                    //如果是c#中没有的类型要插入的话,必须用add方法指定类型
                    com.Parameters.Add(new SqlParameter("@ordersum", SqlDbType.Money));//此处用add方法将新的sql参数对象添加到参数集合中,并指定参数类型
                    com.Parameters["@ordersum"].Value = ordersum;
                    com.Parameters.Add(new SqlParameter("@orderdate", SqlDbType.DateTime));
                    com.Parameters["@orderdate"].Value = orderdate;//这里orderdate可以是任何类型,它最终会被转换为datetime类型的
                    com.ExecuteNonQuery();

                    //将订单的订购数量从库存中减去,更新Goods表的Quantity值即可(利用DataSet["goods"]更新数据库)
                    x["storage"] = Convert.ToInt32(x["storage"]) - Convert.ToInt32(textBox2.Text);
                    MessageBox.Show("库存:" + x["storage"].ToString());
                    SqlCommandBuilder scb = new SqlCommandBuilder(sda);
                    sda.Update(ds, "goods");
                    MessageBox.Show("创建订单成功!");
                    //sda = new SqlDataAdapter("insertorders", con);
                    //sda.InsertCommand.CommandType = CommandType.StoredProcedure;
                    //sda.InsertCommand.Parameters.AddWithValue("@goodsid", goodsid);
                    //sda.InsertCommand.Parameters.AddWithValue("@customerid", customerid);

                    //sda.InsertCommand.Parameters.AddWithValue("@quantity", quantity);
                    //sda.InsertCommand.Parameters.Add("@ordersum", SqlDbType.Money).Value = ordersum;
                    //sda.InsertCommand.Parameters.AddWithValue("@orderdate", SqlDbType.DateTime).Value = orderdate;
                    //sda.InsertCommand.ExecuteNonQuery();
                    //MessageBox.Show("成功!");
                    return;
                }
            }
            MessageBox.Show("没有该商品或商品库存不足!");
        }
 public void UpdateInventory(DataTable modifiedTable)
 {
     dAdapt.Update(modifiedTable);
 }
Exemple #5
0
        public void UpdateAllToolState(object source, System.Timers.ElapsedEventArgs e)
        {
            Dictionary <String, TagInfo> tmpTagDic = (Dictionary <String, TagInfo>)clonedObj;
            int i = 0;

            DataRow[] drs;
            String    EPC;
            String    State;
            TagInfo   tag;

            CoreTabDAMux.WaitOne();
            CoreTabDA.Fill(CoreTabDT);


            foreach (DataRow dr in CoreTabDT.Rows)
            {
                EPC   = dr["EPC"].ToString();
                State = dr["State"].ToString();

                if (tmpTagDic.ContainsKey(EPC)) //实际在库
                {
                    tag            = tmpTagDic[EPC];
                    dr["PosX"]     = tag.PosX;
                    dr["PosY"]     = tag.PosY;
                    dr["LastSeen"] = tag.LastSeen.ToString();

                    if (State == "0") //理论在库
                    {
                        dr["RealState"] = 5;
                    }
                    else if (State == "2")  //理论借出
                    {
                        dr["RealState"] = 6;
                    }
                    else
                    {
                        dr["RealState"] = 0;
                    }
                    tmpTagDic.Remove(EPC); //从tmpTagDic中移除该tag,减小下次dict的查询负担。
                }
                else //实际不在库
                {
                    if (State == "0") //在库
                    {
                        dr["RealState"] = 7;
                    }
                    else if (State == "2")  //借出
                    {
                        dr["RealState"] = 2;
                    }
                    else
                    {
                        dr["RealState"] = 8;
                    }
                }
            }

            SqlCommandBuilder cmd = new SqlCommandBuilder(CoreTabDA);

            CoreTabDA.Update(CoreTabDT);
            CoreTabDAMux.ReleaseMutex();
        }
Exemple #6
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (propertyid == -1)
            {
                Response.Redirect(CommonFunctions.PrepareURL("InternalError.aspx"), true);
            }

            //CommonFunctions.Connection.Open ();

            PropertiesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT * FROM Properties " +
                                                               "WHERE ID = @PropertyID", SqlDbType.Int);
            PhotosAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT * FROM PropertyPhotos " +
                                                           "WHERE PropertyID = @PropertyID", SqlDbType.Int);

            PropertiesAdapter.SelectCommand.Parameters["@PropertyID"].Value = propertyid;
            PhotosAdapter.SelectCommand.Parameters["@PropertyID"].Value     = propertyid;

            //lock (CommonFunctions.Connection)
            if (PropertiesAdapter.Fill(MainDataSet, "Properties") == 0)
            {
                Response.Redirect(CommonFunctions.PrepareURL("InternalError.aspx"), true);
            }
            //lock (CommonFunctions.Connection)
            PhotosAdapter.Fill(MainDataSet, "PropertyPhotos");

            if (((int)MainDataSet.Tables["Properties"].Rows[0]["UserID"] != AuthenticationManager.UserID) &&
                !AuthenticationManager.IfAdmin)
            {
                Response.Redirect(CommonFunctions.PrepareURL("Login.aspx?BackLink=" +
                                                             HttpUtility.UrlEncode(Request.Url.ToString())), true);
            }

            using (SqlConnection connection = CommonFunctions.GetConnection()) {
                connection.Open();
                SqlCommand DeleteCommissions2 = new SqlCommand("DELETE FROM Commissions WHERE EXISTS (SELECT * " +
                                                               "FROM Commissions InnerC INNER JOIN Invoices ON InnerC.InvoiceID = Invoices.ID" +
                                                               " WHERE (Commissions.CommissionID = InnerC.ID) AND (Invoices.PropertyID = @PropertyID))",
                                                               connection);
                DeleteCommissions2.Parameters.Add("@PropertyID", SqlDbType.Int);
                DeleteCommissions2.Parameters["@PropertyID"].Value = propertyid;

                DeleteCommissions2.ExecuteNonQuery();

                SqlCommand DeleteCommissions = new SqlCommand("DELETE FROM Commissions WHERE EXISTS (SELECT * " +
                                                              "FROM Invoices WHERE (Commissions.InvoiceID = Invoices.ID) AND (Invoices.PropertyID = @PropertyID))",
                                                              connection);
                DeleteCommissions.Parameters.Add("@PropertyID", SqlDbType.Int);
                DeleteCommissions.Parameters["@PropertyID"].Value = propertyid;

                DeleteCommissions.ExecuteNonQuery();

                SqlCommand DeleteInvoices = new SqlCommand("DELETE FROM Invoices WHERE PropertyID = @PropertyID",
                                                           connection);
                DeleteInvoices.Parameters.Add("@PropertyID", SqlDbType.Int);
                DeleteInvoices.Parameters["@PropertyID"].Value = propertyid;

                DeleteInvoices.ExecuteNonQuery();

                SqlCommand DeleteReservations = new SqlCommand("DELETE FROM PropertyAvailDates WHERE PropertyID = @PropertyID",
                                                               connection);
                DeleteReservations.Parameters.Add("@PropertyID", SqlDbType.Int);
                DeleteReservations.Parameters["@PropertyID"].Value = propertyid;

                DeleteReservations.ExecuteNonQuery();

                connection.Close();
            }
            MainDataSet.Tables["Properties"].Rows[0].Delete();

            foreach (System.Data.DataRow datarow in MainDataSet.Tables["PropertyPhotos"].Rows)
            {
                if (System.IO.File.Exists(Request.PhysicalApplicationPath + ConfigurationManager.AppSettings["ImagesSubfolderPath"] + datarow["FileName"]))
                {
                    System.IO.File.Delete(Request.PhysicalApplicationPath + ConfigurationManager.AppSettings["ImagesSubfolderPath"] + datarow["FileName"]);
                }
            }

            //lock (CommonFunctions.Connection)
            PropertiesAdapter.Update(MainDataSet, "Properties");

            Response.Redirect(backlinkurl);
        }
Exemple #7
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            if (fuDonorFile.HasFile)
            {
                string strFilePath = HttpContext.Current.Request.PhysicalApplicationPath + @"Uploads\" + Request["eid"].ToString();

                if (!Directory.Exists(strFilePath))
                {
                    Directory.CreateDirectory(strFilePath);
                }

                string strFileName = Guid.NewGuid().ToString() + ".csv";
                fuDonorFile.SaveAs(strFilePath + @"\" + strFileName);

                try
                {
                    try
                    {
                        SqlConnection ConnT = new SqlConnection(_ConnStr);
                        ConnT.Open();
                        SqlCommand cmd = new SqlCommand("DELETE DonorListStage", ConnT);
                        cmd.ExecuteNonQuery();
                        cmd.Dispose();
                        ConnT.Close();
                    }
                    catch (Exception EX)
                    {
                        throw new Exception("T Error: " + EX.Message);
                    }

                    SqlConnection Conn = new SqlConnection(_ConnStr);
                    Conn.Open();
                    SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM DonorListStage", Conn);

                    SqlCommandBuilder cb = new SqlCommandBuilder(da);



                    DataSet ds = new DataSet();
                    try { da.Fill(ds); }
                    catch (Exception EX) { throw new Exception("DA Error: " + EX.Message); }

                    // Read file
                    string   line = "";
                    string[] arrLine;


                    StreamReader file = new StreamReader(strFilePath + @"\" + strFileName);
                    line = file.ReadLine();  // Skip the first line of column headers

                    int intRowCount = 1;
                    while ((line = file.ReadLine()) != null)
                    {
                        int      intCount = line.Split((char)34).Length;
                        string[] arrComma = line.Split((char)34);

                        if (intCount > 2)
                        {
                            line = ReplaceComma(line);
                        }
                        if (intCount > 4)
                        {
                            line = ReplaceComma(line);
                        }
                        if (intCount > 6)
                        {
                            line = ReplaceComma(line);
                        }
                        if (intCount > 8)
                        {
                            line = ReplaceComma(line);
                        }
                        if (intCount > 10)
                        {
                            line = ReplaceComma(line);
                        }
                        if (intCount > 12)
                        {
                            line = ReplaceComma(line);
                        }



                        arrLine = line.Split(",".ToCharArray());
                        DataRow dr = ds.Tables[0].NewRow();

                        if (arrLine.Count() != 31)
                        {
                            dr["pk_DonorList"] = intRowCount.ToString();
                            dr["UploadNotes"]  = "Error: Data not in the correct format.";
                        }
                        else
                        {
                            try
                            {
                                dr["pk_DonorList"]     = arrLine[28].ToString().Replace(";", ",");
                                dr["DonorType"]        = arrLine[2].ToString().Replace(";", ",");
                                dr["AccountType"]      = arrLine[3].ToString().Replace(";", ",");
                                dr["KeyName"]          = arrLine[4].ToString().Replace(";", ",");
                                dr["AccountID"]        = arrLine[5].ToString().Replace(";", ",");
                                dr["InsideSal"]        = arrLine[6].ToString().Replace(";", ",");
                                dr["OutSideSal"]       = arrLine[7].ToString().Replace(";", ",");
                                dr["HHOutsideSal"]     = arrLine[8].ToString().Replace(";", ",");
                                dr["AccountName"]      = arrLine[9].ToString().Replace(";", ",");
                                dr["AddressLine1"]     = arrLine[10].ToString().Replace(";", ",");
                                dr["AddressLine2"]     = arrLine[11].ToString().Replace(";", ",");
                                dr["AddressLine3"]     = arrLine[12].ToString().Replace(";", ",");
                                dr["AddressLine4"]     = arrLine[13].ToString().Replace(";", ",");
                                dr["AddressLine5"]     = arrLine[14].ToString().Replace(";", ",");
                                dr["City"]             = arrLine[15].ToString().Replace(";", ",");
                                dr["State"]            = arrLine[16].ToString().Replace(";", ",");
                                dr["PostCode"]         = arrLine[17].ToString().Replace(";", ",");
                                dr["CountryIDTrans"]   = arrLine[18].ToString().Replace(";", ",");
                                dr["StateDescription"] = arrLine[19].ToString().Replace(";", ",");
                                dr["EmailAddress"]     = arrLine[20].ToString().Replace(";", ",");
                                dr["PhoneNumber"]      = arrLine[21].ToString().Replace(";", ",");

                                if (!arrLine[22].ToString().Equals(""))
                                {
                                    dr["SPLCLeadCouncil"] = arrLine[22].ToString();
                                }

                                if (arrLine[23].ToString().Equals(""))
                                {
                                    dr["MembershipYear"] = 0;
                                }
                                else
                                {
                                    string[] arrMYear = arrLine[23].Split("/".ToCharArray());
                                    dr["MembershipYear"] = int.Parse(arrMYear[2].ToString());
                                }

                                if (arrLine[24].ToString().Equals(""))
                                {
                                    dr["YearsSince"] = 0;
                                }
                                else
                                {
                                    dr["YearsSince"] = int.Parse(arrLine[24].ToString());
                                }

                                if (arrLine[25].ToString().Equals(""))
                                {
                                    dr["HPC"] = 0;
                                }
                                else
                                {
                                    dr["HPC"] = float.Parse(arrLine[25].ToString().Replace("$", "").Replace(";", ","));
                                }

                                if (!arrLine[26].ToString().Equals(""))
                                {
                                    dr["LastPaymentDate"] = DateTime.Parse(arrLine[26].ToString());
                                }

                                if (arrLine[27].ToString().Equals(""))
                                {
                                    dr["LastPaymentAmount"] = 0;
                                }
                                else
                                {
                                    dr["LastPaymentAmount"] = float.Parse(arrLine[27].ToString().Replace("$", "").Replace(";", ","));
                                }


                                dr["SourceCode"] = arrLine[29].ToString();

                                //dr["UploadNotes"] = intRowCount.ToString();
                            }
                            catch (Exception EX)
                            {
                                dr["pk_DonorList"]    = intRowCount.ToString();
                                dr["UploadNotes"]     = "Error: " + EX.Message;
                                lblErrorMessage.Text += " | " + EX.Message;
                            }
                        }

                        ds.Tables[0].Rows.Add(dr);

                        try
                        {
                            da.Update(ds);
                        }
                        catch (Exception EX)
                        {
                            throw new Exception("c:: " + arrLine[28].ToString().Replace(";", ",") + " | " + EX.Message);
                        }

                        intRowCount += 1;
                    }

                    try
                    {
                        //da.Update(ds);
                    }
                    catch (Exception EX)
                    {
                        throw new Exception("c:: " + EX.Message);
                    }

                    cb.Dispose();
                    da.Dispose();

                    SqlDataAdapter daSel = new SqlDataAdapter("SELECT * FROM DonorListStage WHERE UploadNotes IS NOT NULL", Conn);
                    DataSet        dsSel = new DataSet();
                    daSel.Fill(dsSel);

                    if (dsSel.Tables[0].Rows.Count > 0)
                    {
                        pnlGrid.Visible     = true;
                        gvErrors.DataSource = dsSel.Tables[0];
                        gvErrors.DataBind();
                    }
                    else
                    {
                        pnlGrid.Visible = false;
                    }

                    Conn.Close();

                    //pnlProcess.Visible = true;
                    //pnlUpload.Visible = false;
                    //pnlGrid.Visible = false;

                    LoadRecords();
                }
                catch (Exception EX)
                {
                    //lblErrorMessage.Text = EX.Message;
                    lblErrorMessage.Text += " | a: " + EX.Message;
                }
            }
        }
 private void button6_Click(object sender, EventArgs e)
 {
     scb = new SqlCommandBuilder(sda);
     sda.Update(dt);
     MessageBox.Show("Record Updated Successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
Exemple #9
0
        protected void ButtonUpload_Click(object sender, EventArgs e)
        {
            if (FileUpload.HasFile)
            {
                if (TextBoxNewName.Text != "")
                {
                    // TextBoxNewName.Text.Trim
                    if (TextBoxNewName.Text.Substring(0, 1) != " ")
                    {
                        try
                        {
                            string sqlins    = "insert into Items values (@name, @normalInfo, @extraInfo, @origin, @main_Cat, @managers_choice_state, @image)";
                            string filename  = FileUpload.PostedFile.FileName;
                            string path      = Convert.ToString(FileUpload.PostedFile.FileName);
                            string extension = Path.GetExtension(path);
                            string sqlsel    = "SELECT * FROM items";


                            FileUpload.SaveAs(Server.MapPath("~/App_Data/" + TextBoxNewName.Text + extension));
                            FileUpload.SaveAs(Server.MapPath("~/Images/" + TextBoxNewName.Text + extension));
                            TextBoxNewName.Text = "";
                            statusInfo.Text     = "File uploaded, brother " + FileUpload.PostedFile.FileName + FileUpload.PostedFile.ContentLength.ToString() + FileUpload.PostedFile.ContentType + DropDownListCat.SelectedValue.ToString();

                            try
                            {
                                da = new SqlDataAdapter();
                                da.SelectCommand = new SqlCommand(sqlsel, conn);
                                ds = new DataSet();
                                da.Fill(ds, "MyItems");
                                dt = ds.Tables["MyItems"];



                                DataRow newrow = dt.NewRow();
                                newrow["name"]       = TextboxName.Text;
                                newrow["normalInfo"] = TextboxNormalInfo.Text;
                                newrow["extraInfo"]  = TextboxExtraInfo.Text;
                                newrow["origin"]     = Convert.ToInt32(DropDownListOrigin.SelectedValue.ToString());
                                newrow["main_Cat"]   = Convert.ToInt32(DropDownListCat.SelectedValue.ToString());

                                newrow["image"] = Convert.ToString(filename);
                                dt.Rows.Add(newrow);
                                if (CheckBoxStatus.Checked)
                                {
                                    newrow["managers_choice_state"] = 1;
                                }

                                cmd = new SqlCommand(sqlins, conn);
                                cmd.Parameters.Add("@name", SqlDbType.Text, 50, "name");
                                cmd.Parameters.Add("@normalInfo", SqlDbType.Text, 200, "normalInfo");
                                cmd.Parameters.Add("@extraInfo", SqlDbType.Text, 200, "extraInfo");
                                cmd.Parameters.Add("@origin", SqlDbType.Int, 4, "origin");
                                cmd.Parameters.Add("@main_Cat", SqlDbType.Int, 4, "main_Cat");
                                cmd.Parameters.Add("@managers_choice_state", SqlDbType.Int, 4, "managers_choice_state");
                                cmd.Parameters.Add("@image", SqlDbType.Text, 200, "image");

                                da.InsertCommand = cmd;
                                da.Update(ds, "MyItems");
                                UpdateGridview();
                            }
                            catch (Exception ex) {
                                statusInfo.Text = ex.Message + ex.StackTrace;
                            }



                            //   GridViewShippers.DataSource = dt;
                            //  GridViewShippers.DataBind();
                        }
                        catch (Exception ex) {
                            statusInfo.Text = ex.Message + ex.StackTrace;
                        }
                    }
                    else
                    {
                        TextBoxNewName.Text = "Intial space not allowed";
                    }
                }
                else
                {
                    statusInfo.Text = "New filename missing, brother";
                }
            }
            else
            {
                statusInfo.Text = "Wrong Filename, brother";
            }
        }
Exemple #10
0
        private void BtnEdit_Click(object sender, EventArgs e)
        {
            if (Program.UserName == TxtUserName.Text)
            {
                MessageBox.Show("كلمة المرور غير متطابقة", "واى إن للبرمجيات", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (UserPassWord.Text != UserPassWordConfirm.Text)
            {
                MessageBox.Show("كلمة المرور غير متطابقة", "واى إن للبرمجيات", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (TxtId.Text == string.Empty || TxtUserName.Text == string.Empty || UserPassWord.Text == string.Empty ||
                UserPassWordConfirm.Text == string.Empty || TxtFullName.Text == string.Empty || CmbType.SelectedItem == null)
            {
                MessageBox.Show("رجاء اكمال البيانات!!", "واى إن للبرمجيات", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            DialogResult dialog = MessageBox.Show("هل انت متأكد من انك تريد تعديل البيانات؟", "واى إن للبرمجيات", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialog == DialogResult.No)
            {
                return;
            }

            try
            {
                SqlDataAdapter adp = new SqlDataAdapter("select * from Tb_Users where UserName = N'" + TxtUserName.Text + "'", con);
                DataSet        ds  = new DataSet();
                adp.Fill(ds);
                DataTable dt = new DataTable();
                dt = ds.Tables[0];
                if (dt.Rows.Count == 0)
                {
                    MessageBox.Show("إسم المستخدم موجود مسبقا", "واى إن للبرمجيات", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                DataRow r = dt.Rows[0];


                r[0]  = TxtId.Text;
                r[1]  = TxtUserName.Text;
                r[2]  = UserPassWord.Text;
                r[3]  = TxtFullName.Text;
                r[4]  = DateUser.EditValue;
                r[5]  = CmbType.Text;
                r[6]  = M1.Checked;
                r[7]  = M2.Checked;
                r[8]  = M3.Checked;
                r[9]  = M4.Checked;
                r[10] = M5.Checked;
                r[11] = M6.Checked;
                r[12] = M7.Checked;
                r[13] = M8.Checked;
                r[14] = M9.Checked;
                r[15] = M10.Checked;
                r[16] = M11.Checked;
                r[17] = M12.Checked;
                r[18] = M13.Checked;
                r[19] = M14.Checked;
                r[20] = M15.Checked;
                r[21] = M16.Checked;
                r[22] = M17.Checked;
                r[23] = M18.Checked;
                r[24] = M19.Checked;
                r[25] = M20.Checked;
                r[26] = M21.Checked;
                r[27] = M22.Checked;
                r[28] = M23.Checked;
                r[23] = M24.Checked;
                r[30] = M25.Checked;
                r[31] = M26.Checked;
                r[32] = M27.Checked;
                r[33] = M28.Checked;
                r[34] = M29.Checked;
                r[35] = M30.Checked;
                r[36] = M31.Checked;
                r[37] = M32.Checked;
                r[38] = M33.Checked;
                r[39] = M34.Checked;
                r[40] = M35.Checked;
                r[41] = M36.Checked;
                r[42] = M37.Checked;
                r[43] = M38.Checked;
                r[44] = M39.Checked;
                r[45] = M40.Checked;
                r[46] = M41.Checked;
                r[47] = M42.Checked;
                r[48] = M43.Checked;
                r[49] = M44.Checked;
                r[50] = M45.Checked;
                r[51] = M46.Checked;
                r[52] = M47.Checked;
                r[53] = M48.Checked;
                r[54] = M49.Checked;
                r[55] = M50.Checked;



                SqlCommandBuilder cmd_Builder1 = new SqlCommandBuilder(adp);
                adp.Update(dt);

                MessageBox.Show("تم تعديل المستخدم بنجاح", "إضافة مستخدم جديد", MessageBoxButtons.OK, MessageBoxIcon.Information);
                clear();
                DGvPreview();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #11
0
        public void Update()
        {
            SqlCommandBuilder comandbuilder = new SqlCommandBuilder(adapter);

            adapter.Update(Resourses);
        }
Exemple #12
0
        protected void btnAddProduct_Click(object sender, EventArgs e)
        {
            try
            {
                DataSet ds = new DataSet();
                adp.Fill(ds, "Prod");
                DataRow dr = ds.Tables["Prod"].NewRow();

                DataSet rateds = new DataSet();
                rateadp.Fill(rateds, "Rate");
                DataRow dq = rateds.Tables["Rate"].NewRow();
                dr[0] = txtProductID.Text;
                dr[1] = txtProductName.Text;
                dr[2] = txtDescription.Text;
                //string effDate = txtEffDate.Text;
                //string endDate = txtEndDate.Text;
                //String.Format("{0:dd/MM/yyyy}",effDate);
                //String.Format("{0:dd/MM/yyyy}", endDate);


                //   IMPORTANT modification
                dr[3] = txtEffDate.Text;//change this to ONLY DATE!
                dr[4] = txtEndDate.Text;
                dr[5] = ddlServiceType.SelectedValue;
                dr[6] = "N";
                dr[8] = DateTime.Now.ToString();

                //Rates Table
                dq[1] = txtProductID.Text;
                dq[2] = double.Parse(txtamount.Text);
                dq[3] = ddstate.Text;
                dq[4] = txtEffDate.Text;
                dq[5] = txtEndDate.Text;
                dq[6] = "N";
                dq[8] = DateTime.Now.ToString();
                dq[9] = Int32.Parse(txtDiscount.Text);



                ds.Tables["Prod"].Rows.Add(dr);

                SqlCommandBuilder com = new SqlCommandBuilder(adp);
                adp.InsertCommand = com.GetInsertCommand();
                adp.Update(ds, "Prod");

                rateds.Tables["Rate"].Rows.Add(dq);

                SqlCommandBuilder com1 = new SqlCommandBuilder(rateadp);
                rateadp.InsertCommand = com1.GetInsertCommand();
                rateadp.Update(rateds, "Rate");
                flag = 1;

                ClientScript.RegisterStartupScript(this.GetType(), "Success", "<script type='text/javascript'>alert('Product Added Successfully!');window.location='Show_Products.aspx';</script>'");
            }
            catch (SqlException ex)
            {
                switch (ex.Number)
                {
                case 4060:     // Invalid Database
                    ClientScript.RegisterStartupScript(this.GetType(), "Success", "<script type='text/javascript'>alert('Some Error Occured!');window.location='Show_Products.aspx';</script>'");
                    break;

                case 18456:     // Login Failed

                    ClientScript.RegisterStartupScript(this.GetType(), "Success", "<script type='text/javascript'>alert('Some Error Occured!');window.location='Show_Products.aspx';</script>'");
                    break;

                case 547:     // ForeignKey Violation

                    ClientScript.RegisterStartupScript(this.GetType(), "Success", "<script type='text/javascript'>alert('Some Error Occured!');window.location='Show_Products.aspx';</script>'");
                    break;

                case 2627:     // Unique Index/ Primary key Violation/ Constriant Violation
                    ClientScript.RegisterStartupScript(this.GetType(), "Success", "<script type='text/javascript'>alert('Product Id Already Exists!');window.location='Add_Product.aspx';</script>'");

                    break;

                case 2601:     // Unique Index/Constriant Violation
                    ClientScript.RegisterStartupScript(this.GetType(), "Success", "<script type='text/javascript'>alert('Some Error Occured!');window.location='Show_Products.aspx';</script>'");
                    break;

                default:
                    ClientScript.RegisterStartupScript(this.GetType(), "Success", "<script type='text/javascript'>alert('Some Error Occured!');window.location='Homepage.aspx';</script>'");
                    break;
                }
            }
        }
Exemple #13
0
        public override bool UpdateDocument()
        {
            var    sql     = new SqlConnection(connectionString);
            string sqlbody = @"SELECT DocumentID, DataHour, ProductID, DataValue1 FROM " +
                             bodyTable + " WHERE DocumentID = " + Head.DocumentNumber.ToString();
            SqlDataAdapter    adapter = new SqlDataAdapter(sqlbody, sql);
            SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
            DataTable         data    = new DataTable();

            try
            {
                adapter.Fill(data);
            }
            catch (Exception exception)
            {
                throw new Exception("Ошибка загрузки документа.", exception);
            }
            DataColumn key1 = data.Columns["DataHour"];
            DataColumn key2 = data.Columns["ProductID"];

            data.PrimaryKey = new DataColumn[] { key1, key2 };

            foreach (DataRow row in DocumentBody.Rows)
            {
                foreach (var device in deviceList)
                {
                    if (data.Rows.Contains(new object[] { row["DataHour"], device }))
                    {
                        DataRow edit = data.Rows.Find(new object[] { row["DataHour"], device });
                        edit.BeginEdit();
                        if (row[device.ToString()].GetType() == typeof(bool))
                        {
                            edit["DataValue1"] = (bool)row[device.ToString()] ? 1.0 : 0.0;
                        }
                        else
                        {
                            edit["DataValue1"] = row[device.ToString()];
                        }
                        edit.EndEdit();
                    }
                    else
                    {
                        DataRow add = data.NewRow();
                        add["DocumentID"] = Head.DocumentNumber;
                        add["DataHour"]   = row["DataHour"];
                        add["ProductID"]  = device;
                        if (row[device.ToString()].GetType() == typeof(bool))
                        {
                            add["DataValue1"] = (bool)row[device.ToString()] ? 1.0 : 0.0;
                        }
                        else
                        {
                            add["DataValue1"] = row[device.ToString()];
                        }
                        data.Rows.Add(add);
                    }
                }
            }
            try
            {
                adapter.Update(data);
            }
            catch (Exception exception)
            {
                error = exception;
                return(false);
                //throw new Exception("Ошибка обновления документа.", exception);
            }
            return(true);
        }
Exemple #14
0
        protected override bool  SaveDocument()
        {
            var    sql     = new SqlConnection(connectionString);
            string sqlhead = string.Format("INSERT INTO {4}(DocumentID, DocumentDate, FactoryID, DocTypeID) VALUES({0},'{1}',{2},{3})", Head.DocumentNumber, Head.DocumentDate.ToString("yyyyMMdd"), Head.Factory, Head.DocType, headTable);

            try
            {
                sql.Open();
            }
            catch (Exception exception)
            {
                error = exception;
                return(false);
                //throw new Exception("Не удалось установить связь с Сервером.", exception);
            }
            var tx  = sql.BeginTransaction();
            var cmd = new SqlCommand(sqlhead, sql, tx);

            try
            {
                cmd.ExecuteNonQuery();
                //tx.Commit();
            }
            catch (Exception exception)
            {
                error = exception;
                tx.Rollback();
                sql.Close();
                return(false);
                //throw new Exception("Документ с заданным номером уже существует.", exception);
            }
            var sqlbody = @"SELECT DocumentID, DataHour, ProductID, DataValue1 FROM " +
                          bodyTable + " WHERE DocumentID = " + Head.DocumentNumber.ToString();
            var cmdbody = new SqlCommand(sqlbody, sql, tx);
            var adapter = new SqlDataAdapter(cmdbody);
            var builder = new SqlCommandBuilder(adapter);
            var data    = new DataTable();

            try
            {
                adapter.Fill(data);
            }
            catch (Exception exception)
            {
                error = exception;
                tx.Rollback();
                sql.Close();
                return(false);
                //throw new Exception("Ошибка загрузки документа.", exception);
            }
            DataColumn key1 = data.Columns["DataHour"];
            DataColumn key2 = data.Columns["ProductID"];

            data.PrimaryKey = new DataColumn[] { key1, key2 };

            //devices
            foreach (DataRow row in DocumentBody.Rows)
            {
                foreach (var device in deviceList)
                {
                    if (data.Rows.Contains(new object[] { row["DataHour"], device }))
                    {
                        DataRow edit = data.Rows.Find(new object[] { row["DataHour"], device });
                        edit.BeginEdit();
                        if (row[device.ToString()].GetType() == typeof(bool))
                        {
                            edit["DataValue1"] = (bool)row[device.ToString()] ? 1.0 : 0.0;
                        }
                        else
                        {
                            edit["DataValue1"] = row[device.ToString()];
                        }
                        edit.EndEdit();
                    }
                    else
                    {
                        DataRow add = data.NewRow();
                        add["DocumentID"] = Head.DocumentNumber;
                        add["DataHour"]   = row["DataHour"];
                        add["ProductID"]  = device;
                        if (row[device.ToString()].GetType() == typeof(bool))
                        {
                            add["DataValue1"] = (bool)row[device.ToString()] ? 1.0 : 0.0;
                        }
                        else
                        {
                            add["DataValue1"] = row[device.ToString()];
                        }
                        data.Rows.Add(add);
                    }
                }
            }
            try
            {
                adapter.Update(data);
                tx.Commit();
            }
            catch (Exception exception)
            {
                error = exception;
                tx.Rollback();
                return(false);
                //throw new Exception("Ошибка загрузки документа.", exception);
            }
            sql.Close();
            return(true);
        }
Exemple #15
0
 private void button1_Click(object sender, EventArgs e)
 {
     adaptador1.Update(midataset, "Factura");
 }
 // This method is used to update the database based on the changes made to the data in a DataSet.
 // Inputs: the DataSet used to update the database.
 public void CommitDataSet(DataSet theDataSet)
 {
     SqlDataAdapter myDataAdapter = new SqlDataAdapter();
     myDataAdapter.Update(theDataSet);
 }
Exemple #17
0
 internal void Update() => adapter.Update(DataSet);
 public void update()
 {
     da.Update(dt);
 }
Exemple #19
0
 private void SaveToolStripButton_Click(object sender, EventArgs e)
 {
     cmdbl = new SqlCommandBuilder(da1);
     da1.Update(ds1, "Pelaths_Table");
     MessageBox.Show("Information Updated");
 }
Exemple #20
0
 private void submitButton_Click(object sender, System.EventArgs e)
 {
     // Update the database with the user's changes.
     dataAdapter.Update((DataTable)bindingSource1.DataSource);
 }
Exemple #21
0
        private void btnXacNhan_Click(object sender, EventArgs e)
        {
            string str = "Select * from HoaDon";

            da = new SqlDataAdapter(str, kn.con);
            ds = new DataSet();
            da.Fill(ds, "HoaDon");

            string str2 = "Select * from PhieuOrder";

            da2 = new SqlDataAdapter(str2, kn.con);
            ds2 = new DataSet();
            da2.Fill(ds2, "PhieuOrder");


            try
            {
                string  MAHD = ds.Tables["HoaDon"].Rows.Count + 1 + "";
                DataRow dr   = ds.Tables["HoaDon"].NewRow();
                dr["MaHoaDon"] = "HD" + MAHD;
                if (txtMaKH.Text.Length != 0)
                {
                    dr["MaKH"] = txtMaKH.Text;
                }
                else
                {
                    dr["MaKH"] = "UNKNOW"; // Khách Chưa đăng ký thành viên
                }
                dr["TongTien"]   = TinhTong();
                dr["NgayXuatHD"] = DateTime.Now.Date;

                if (rdoMangDi.Checked)
                {
                    dr["MaDichVu"] = "TA";
                }
                else
                {
                    dr["MaDichVu"] = "EI";
                }
                ds.Tables["HoaDon"].Rows.Add(dr);
                SqlCommandBuilder bd = new SqlCommandBuilder(da);
                da.Update(ds, "HoaDon");


                foreach (ListViewItem item in lstSelect.Items)
                {
                    DataRow dr2 = ds2.Tables["PhieuOrder"].NewRow();
                    dr2["MaPhieu"] = (ds2.Tables["PhieuOrder"].Rows.Count + 1);
                    if (txtMaKH.Text.Length != 0)
                    {
                        dr["MaKH"] = txtMaKH.Text;
                    }
                    else
                    {
                        dr["MaKH"] = "UNKNOW"; // Khách Chưa đăng ký thành viên
                    }
                    dr2["MaKH"]     = "NV01";
                    dr2["MaMon"]    = item.SubItems[0].Text;
                    dr2["SoLuong"]  = item.SubItems[2].Text;
                    dr2["TongTien"] = item.SubItems[4].Text;
                    //dr2["MaHoaDon"] = "HD" + (ds.Tables["HoaDon"].Rows.Count + 1);
                    dr2["MaHoadON"] = "HD" + MAHD;
                    ds2.Tables["PhieuOrder"].Rows.Add(dr2);
                }
                SqlCommandBuilder bd2 = new SqlCommandBuilder(da2);
                da2.Update(ds2, "PhieuOrder");
                MessageBox.Show("Thanh toán thành công");
                RPHoaDon hd = new RPHoaDon("HD" + MAHD);
                hd.Visible = true;
                this.Close();
            }
            catch
            {
                MessageBox.Show("Đặt hàng thất bại", "Lỗi");
                ds.Tables["HoaDon"].Reset();
                ds2.Tables["PhieuOrder"].Reset();
            }
        }
Exemple #22
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     da.Update(dtBooks);
 }
Exemple #23
0
        /// <summary>
        /// This function will Updated the Dataset of AssessementNeedList
        /// </summary>
        /// <param name="DataSetAssessmentNeedlist"></param>
        /// <returns></returns>
        public DataSet UpdateAssessementNeedList(DataSet DataSetAssessmentNeedlist)
        {
            try
            {
                //Storing DataSetAssessmentNeedlist into DataSetAssessmentNeed so that it can be assess OnRowUpdated
                DataSetAssessmentNeed = DataSetAssessmentNeedlist;
                string    _SelectQuery = "";
                DataTable dtDocuments  = null;
                if (DataSetAssessmentNeedlist.Tables.Contains("Documents"))
                {
                    dtDocuments = DataSetAssessmentNeedlist.Tables["Documents"].Copy();
                    DataSetAssessmentNeedlist.Tables.Remove("Documents");
                }

                //Create a new dataset with the same structure of the dataset passed to the function.
                // To maintain all the keys and constraints of the dataset.
                DataSet datasetUpdated = DataSetAssessmentNeedlist.Clone();
                int     _TableCount;
                int     _documentId = 0;
                int     _version    = 0;

                try
                {
                    SqlConnectionObject = new SqlConnection(_ConnectionString);
                    SqlConnectionObject.Open();
                    SqlTransactionObject = SqlConnectionObject.BeginTransaction();
                }
                catch (SqlException sqlEx)
                {
                    throw sqlEx;
                }

                if (DataSetAssessmentNeedlist.Tables.Count > 0)
                {
                    if (DataSetAssessmentNeedlist.Tables[0].Rows.Count > 0)
                    {
                        SqlParameter[] SqlParametersCollection = new SqlParameter[15];
                        SqlParametersCollection[0] = new SqlParameter("@ClientId", dtDocuments.Rows[0]["ClientId"]);
                        SqlParametersCollection[1] = new SqlParameter("@ServiceId", dtDocuments.Rows[0]["ServiceId"]);
                        SqlParametersCollection[2] = new SqlParameter("@DocumentCodeId", dtDocuments.Rows[0]["DocumentCodeId"]);
                        SqlParametersCollection[3] = new SqlParameter("@Status", dtDocuments.Rows[0]["Status"]);
                        SqlParametersCollection[4] = new SqlParameter("@AuthorId", dtDocuments.Rows[0]["AuthorId"]);
                        SqlParametersCollection[5] = new SqlParameter("@EffectiveDate", dtDocuments.Rows[0]["EffectiveDate"]);
                        SqlParametersCollection[6] = new SqlParameter("@DocumentId", Convert.ToInt32(DataSetAssessmentNeedlist.Tables["CustomHRMAssessmentNeeds"].Rows[0]["DocumentId"]));

                        SqlParametersCollection[7]  = new SqlParameter("@Version", Convert.ToInt32(DataSetAssessmentNeedlist.Tables["CustomHRMAssessmentNeeds"].Rows[0]["Version"]));
                        SqlParametersCollection[8]  = new SqlParameter("@ExternalRefId", dtDocuments.Rows[0]["ExternalRefId"]);
                        SqlParametersCollection[9]  = new SqlParameter("@CreatedBy", dtDocuments.Rows[0]["CreatedBy"]);
                        SqlParametersCollection[10] = new SqlParameter("@CreatedDate", System.DateTime.Now);
                        SqlParametersCollection[11] = new SqlParameter("@ModifiedBy", dtDocuments.Rows[0]["ModifiedBy"]);
                        SqlParametersCollection[12] = new SqlParameter("@ModifiedDate", System.DateTime.Now);
                        SqlParametersCollection[13] = new SqlParameter("@ToSign", dtDocuments.Rows[0]["ToSign"]);
                        SqlParametersCollection[14] = new SqlParameter("@ProxyId", dtDocuments.Rows[0]["ProxyId"]);



                        //_ParametersObject[6].Direction = ParameterDirection.InputOutput  ;
                        //_ParametersObject[7].Direction = ParameterDirection.InputOutput;
                        using (DataSet dsTemp = SqlHelper.ExecuteDataset(_ConnectionString, CommandType.StoredProcedure, "ssp_SCInsertNewDocumentAndVersion", SqlParametersCollection))
                        {
                            if (dsTemp.Tables.Count > 0)
                            {
                                _documentId = Convert.ToInt32(dsTemp.Tables[0].Rows[0]["DocumentId"]);
                                _version    = Convert.ToInt32(dsTemp.Tables[0].Rows[0]["Version"]);
                            }
                        }

                        //if (SqlHelper.ExecuteNonQuery(_ConnectionString, CommandType.StoredProcedure, "ssp_SCInsertNewDocumentAndVersion", SqlParametersCollection) > 0)
                        //{
                        //     _documentId = Convert.ToInt32(SqlParametersCollection[6].Value);
                        //     _version = Convert.ToInt32(SqlParametersCollection[7].Value);
                        //}
                    }
                }


                for (_TableCount = 0; _TableCount <= DataSetAssessmentNeedlist.Tables.Count - 1; _TableCount++)
                {
                    foreach (DataRow dr in DataSetAssessmentNeedlist.Tables[_TableCount].Rows)
                    {
                        if (DataSetAssessmentNeedlist.Tables[_TableCount].TableName == "CustomHRMAssessmentNeeds")
                        {
                            dr["DocumentId"] = _documentId;
                            dr["Version"]    = _version;
                            //dr["HRMNeedId"] = 1;
                        }
                    }

                    //_SelectQuery = "Select * from " + DataSetAssessmentNeedlist.Tables[_TableCount];
                    _SelectQuery = Streamline.DataService.ApplicationCommonFunctions.GetSelectSQL(DataSetAssessmentNeedlist.Tables[_TableCount]);

                    SqlCommand sqlSelectCommand;
                    sqlSelectCommand = new SqlCommand(_SelectQuery, SqlConnectionObject, SqlTransactionObject);
                    SqlDataAdapter    _SqlDataAdapter    = new SqlDataAdapter(sqlSelectCommand);
                    SqlCommandBuilder _SqlCommandBuilder = new SqlCommandBuilder(_SqlDataAdapter);
                    _SqlDataAdapter.InsertCommand             = _SqlCommandBuilder.GetInsertCommand();
                    _SqlDataAdapter.UpdateCommand             = _SqlCommandBuilder.GetUpdateCommand();
                    _SqlDataAdapter.InsertCommand.Transaction = SqlTransactionObject;
                    _SqlDataAdapter.UpdateCommand.Transaction = SqlTransactionObject;

                    if (DataSetAssessmentNeedlist.Tables[_TableCount].TableName == "CustomHRMNeeds")
                    {
                        _SqlDataAdapter.RowUpdated += new SqlRowUpdatedEventHandler(OnRowUpdated);
                    }
                    _SqlDataAdapter.Update(DataSetAssessmentNeedlist.Tables[_TableCount]);
                    //datasetUpdated.Merge(getData(DataSetAssessmentNeedlist.Tables[_TableCount].PrimaryKey, DataSetAssessmentNeedlist.Tables[_TableCount].TableName, SqlTransactionObject));
                }

                SqlTransactionObject.Commit();

                //datasetUpdated = SqlHelper.ExecuteDataset(SqlConnectionObject, CommandType.StoredProcedure, "csp_DwPAAddUpdateSmartCare");

                return(DataSetAssessmentNeedlist);
            }
            catch (Exception ex)
            {
                SqlTransactionObject.Rollback();
                if (ex.Data["CustomExceptionInformation"] == null)
                {
                    ex.Data["CustomExceptionInformation"] = "###Source Function Name - UpdateDocuments(), ParameterCount - 1, First Parameter- " + DataSetAssessmentNeedlist + "###";
                }
                if (ex.Data["DatasetInfo"] == null)
                {
                    ex.Data["DatasetInfo"] = null;
                }
                throw (ex);
            }
        }
Exemple #24
0
        private void Button1_Click(object sender, EventArgs e)
        {
            SqlCommandBuilder b1 = new SqlCommandBuilder(da);

            da.Update(ds, "products");
        }
Exemple #25
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            string childTableName = ConfigurationSettings.AppSettings["childTableName"];

            daCopii.Update(ds, childTableName);
        }
Exemple #26
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (RoleName.Text == "")
            {
                MessageBox.Show("组名不能为空", "警告");
                return;
            }
            string sql = "SELECT COUNT(*) tj   FROM tRole WHERE(RoleName = '" + RoleName.Text + "')";

            try
            {
                dm1.Tables["tRole1"].Clear();
            }
            catch { }
            SqlDataAdapter t1 = new SqlDataAdapter(sql, conn);

            t1 = new SqlDataAdapter(sql, conn);
            t1.Fill(dm1, "tRole1");

            if (dm1.Tables["tRole1"].Rows[0]["tj"].ToString() != "0")
            {
                MessageBox.Show("该组已存在请更换名称", "失败");
                return;
            }
            if (lx == 0)
            {
                string sql1 = "SELECT RoleName,RoleMemo  FROM tRole where 1=2 ";
                try
                {
                    dm1.Tables["tRole"].Clear();
                }
                catch { }
                tRoleTA1 = new SqlDataAdapter(sql1, conn);
                tRoleTA1.Fill(dm1, "tRole");
                DataRow dr = dm1.Tables["tRole"].NewRow();

                dr["RoleName"] = RoleName.Text;
                dr["RoleMemo"] = RoleMemo.Text;
                //  dm1.tUser1.Rows.Add(dr);
                dm1.Tables["tRole"].Rows.Add(dr);
                SqlCommandBuilder sb1 = new SqlCommandBuilder(tRoleTA1);
                tRoleTA1.Update(dm1.Tables["tRole"]);

                string sql2 = "SELECT RoleID AS 编号, RoleName AS 名称, RoleMemo AS 备注 FROM tRole where RoleName ='" + RoleName.Text + "'";
                try
                {
                    dm1.Tables["tRole"].Clear();
                }
                catch { }
                tRoleTA1 = new SqlDataAdapter(sql2, conn);
                tRoleTA1.Fill(dm1, "tRole");
                roleid = dm1.Tables["tRole"].Rows[0]["编号"].ToString();
                qxgl.ColumnsChang("trole");
                button1.Enabled = true;
                button3.Enabled = false;
            }
            else
            {
                //修改


                try
                {
                    dm1.Tables["tRole"].Rows[0].EndEdit();
                    tRoleTA1.Update(dm1.Tables["tRole"]);
                    // Globals.SysLogChangeEvent(this.Name, "编号", dm1.tRole);
                    //dm1.tRole.AcceptChanges();
                }
                catch (ArgumentNullException) { }
                this.Close();
            }
        }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string uId = ViewState["uId"].ToString();

        if (objUtl.CheckExistence("LoginId", "UserDetails", "LoginId = '" + txtLoginId.Text + "' And UserId <> '" + ViewState["uId"].ToString() + "' "))
        {
            objUtl.ShowMessage("Information", "<b>INFORMATION!</b> GIVEN LOGIN ID (" + txtLoginId.Text + ") ALREADY EXIST IN DATABASE!", lblMessage);
        }
        else
        {
            SqlConnection sCon     = objUtl.CreateSqlConnection(new SqlConnection());
            string        sqlQuery = "";
            if (ViewState["opCode"].Equals(0))
            {
                sqlQuery = "Select * From UserDetails Where 1 = 2";
                uId      = System.Guid.NewGuid().ToString();
            }
            else if (ViewState["opCode"].Equals(1))
            {
                sqlQuery = "Select * From UserDetails Where UserId = '" + uId + "'";
            }
            SqlDataAdapter    sDta    = new SqlDataAdapter(sqlQuery, sCon);
            SqlCommandBuilder sCmb    = new SqlCommandBuilder(sDta);
            DataTable         dtTable = new DataTable();
            sDta.Fill(dtTable);
            DataRow dtRow;
            if (dtTable.Rows.Count > 0)
            {
                dtRow = dtTable.Rows[0];
            }
            else
            {
                dtRow = dtTable.NewRow();
            }
            try
            {
                RijndaelManaged obRjm = new RijndaelManaged();
                obRjm.GenerateKey();
                obRjm.GenerateIV();
                byte[] myKey = null;
                byte[] myIv  = null;
                myKey = obRjm.Key;
                myIv  = obRjm.IV;
                string encryptionText, encryptionKey, encryptionIv;
                encryptionKey  = Convert.ToBase64String(myKey);
                encryptionIv   = Convert.ToBase64String(myIv);
                encryptionText = objEnc.EncryptText(txtPassword.Text, encryptionKey, encryptionIv);

                dtRow["UserId"]      = uId.ToString();
                dtRow["UserName"]    = txtName.Text;
                dtRow["UserRole"]    = ddlRole.SelectedValue;
                dtRow["LoginStatus"] = 1;
                dtRow["Email"]       = txtEmail.Text;
                dtRow["PhoneNo"]     = txtPhoneNo.Text;
                if (ViewState["opCode"].Equals(0))
                {
                    dtRow["LoginId"]                = txtLoginId.Text;
                    dtRow["LoginPassword"]          = encryptionText.ToString();
                    dtRow["PasswordKey"]            = encryptionKey.ToString();
                    dtRow["PasswordIv"]             = encryptionIv.ToString();
                    dtRow["CreationDate"]           = System.DateTime.Now.ToString("MM-dd-yyyy hh:mm:ss");
                    dtRow["CreationBy"]             = Session["UserId"].ToString();
                    dtRow["LastLoginDate"]          = System.DateTime.Now.ToString("MM-dd-yyyy hh:mm:ss");
                    dtRow["LastPasswordChangeDate"] = System.DateTime.Now.ToString("MM-dd-yyyy hh:mm:ss");
                }
                else
                {
                    dtRow["ModificationDate"] = System.DateTime.Now.ToString("MM-dd-yyyy hh:mm:ss");
                    dtRow["ModificationBy"]   = Session["UserId"].ToString();
                }
                if (dtTable.Rows.Count == 0)
                {
                    dtTable.Rows.Add(dtRow);
                }
                sDta.Update(dtTable);
                objUtl.ShowMessage("Success", "<b>SUCCESS!</b> RECORD HAS BEEN SAVED SUCCESSFULLY.", lblMessage);
                ClearText();
                sDta.Dispose();
                dtTable             = null;
                ViewState["opCode"] = 0;
                ViewState["uId"]    = "";
            }
            catch (Exception ex)
            {
                objUtl.ShowMessage("Error", "<b>ERROR!</b> ERROR IN SAVING RECORD, PLEASE TRY AGAIN OR CONTACT THE ADMINISTRATOR.", lblMessage);
            }
            sCon.Close();
            sCon.Dispose();
        }
    }
Exemple #28
0
        //保存项目信息
        private void button1_Click_1(object sender, EventArgs e)
        {//下面的东西需要修改
            //通过ID来索引项目,加载进来
            //打开数据库
            SqlConnection sqlCont = new SqlConnection(Jingtai.ConnectionString); //创建数据库连接

            if (sqlCont.State == ConnectionState.Open)                           //检查连接状态
            {
                sqlCont.Close();
            }
            sqlCont.Open();       //打开数据库连接
            String         searchStr = "select * from Table_Ku where id='" + Jingtai.myid + "'";
            DataSet        ds        = new DataSet();
            SqlDataAdapter dataAdpt  = new SqlDataAdapter(searchStr, sqlCont); //执行查询

            dataAdpt.Fill(ds, "Table_Ku");                                     //填充完毕

            //textBoxNIAN.Text = ds.Tables[0].Rows[0][5].ToString();
            //textBoxBIANHAO.Text = ds.Tables[0].Rows[0][6].ToString();
            //textBoxWEITUOREN.Text = ds.Tables[0].Rows[0][4].ToString();
            //textBoxXINGZHI.Text = ds.Tables[0].Rows[0][2].ToString();
            //textBoxBUMEN.Text = ds.Tables[0].Rows[0][3].ToString();
            //textBoxSHENQINGREN.Text = ds.Tables[0].Rows[0][1].ToString();
            //textBoxBEIZHU.Text = ds.Tables[0].Rows[0][7].ToString();

            //更新到数据库中 基础信息,
            ds.Tables[0].Rows[0][9]  = textBoxDIANHUA.Text;
            ds.Tables[0].Rows[0][10] = textBoxSUOYOUQUAN.Text;
            ds.Tables[0].Rows[0][11] = textBoxZHENGHAO.Text;
            ds.Tables[0].Rows[0][12] = textBoxCHANJI.Text;
            ds.Tables[0].Rows[0][13] = textBoxZUOLUO.Text;
            ds.Tables[0].Rows[0][14] = textBoxLEIQU.Text;
            ds.Tables[0].Rows[0][15] = textBox1NIANDAI.Text;
            ds.Tables[0].Rows[0][16] = textBoxSHEJIYONGTU.Text;
            ds.Tables[0].Rows[0][17] = textBoxGONGJIAOCHE.Text;
            ds.Tables[0].Rows[0][18] = textBoxJIANZHUMIANJI.Text;
            ds.Tables[0].Rows[0][19] = textBoxBEI.Text;
            ds.Tables[0].Rows[0][20] = textBoxNAN.Text;
            ds.Tables[0].Rows[0][21] = textBoxXI.Text;
            ds.Tables[0].Rows[0][22] = textBoxDONG.Text;
            ds.Tables[0].Rows[0][23] = textBox1TUDIMIANJI.Text;
            ds.Tables[0].Rows[0][24] = textBoxTUDIYONGTU.Text;
            ds.Tables[0].Rows[0][25] = textBoxQUDEFANGSHI.Text;
            ds.Tables[0].Rows[0][26] = textBoxTUDIJIBIE.Text;
            ds.Tables[0].Rows[0][27] = textBoxMIAOSHUFANG.Text;
            ds.Tables[0].Rows[0][28] = textBoxMIAOSHUQUAN.Text;
            ds.Tables[0].Rows[0][29] = textBoxMIAOSHUTUDI.Text;
            //再单独更新进去委托人和备注
            ds.Tables[0].Rows[0][4] = textBoxWEITUOREN.Text;
            ds.Tables[0].Rows[0][7] = textBoxBEIZHU.Text;

            //保存案例ID

            ds.Tables[0].Rows[0][31] = textBoxANLIIDA.Text;
            ds.Tables[0].Rows[0][32] = textBoxANLIIDB.Text;
            ds.Tables[0].Rows[0][33] = textBoxANLIIDC.Text;

            SqlCommandBuilder baseInsertCommand = new SqlCommandBuilder(dataAdpt);

            dataAdpt.Update(ds, "Table_Ku");



            //更新到数据库中
            sqlCont.Close();
        }
Exemple #29
0
 private void BtnActualizar_Click(object sender, EventArgs e)
 {
     adapter.Update(ds, "VEHÍCULOS");
     MessageBox.Show("ACTUALIZADO");
 }
Exemple #30
0
 private void btnDel_Click(object sender, EventArgs e)
 {
     adapter.Update(dataSet.Tables["Book"].Select(null, null, DataViewRowState.Deleted));
 }
Exemple #31
0
 public static DataGridView RefreshReturnGridView(DataGridView dgv, string query, SqlConnection scon)
 {
     SqlCommand queryGrid = new SqlCommand(query, scon);
     SqlDataAdapter sAdapt = new SqlDataAdapter(queryGrid);
     sAdapt.SelectCommand = queryGrid;
     DataTable dTab = new DataTable();
     sAdapt.Fill(dTab);
     BindingSource b = new BindingSource();
     b.DataSource = dTab;
     dgv.DataSource = b;
     sAdapt.Update(dTab);
     return dgv;
 }