Exemple #1
0
        private void exportxmlbutton_Click(object sender, EventArgs e)
        {
            DateTime time1 = Convert.ToDateTime(this.dateTimePickerstart.Value.Date.ToString("yyyy/MM/dd"));
            DateTime time2 = Convert.ToDateTime(this.dateTimePickerend.Value.Date.ToString("yyyy/MM/dd"));

            if (DateTime.Compare(time1, time2) > 0) //判断日期大小
            {
                MessageBox.Show("开始日期大于结束");
                return;
            }

            string startTime = this.dateTimePickerstart.Value.ToString("yyyy/MM/dd");
            string endTime   = this.dateTimePickerend.Value.ToString("yyyy/MM/dd");

            List <ReceiveOrderStruct> receiveOrderList = new List <ReceiveOrderStruct>();

            try
            {
                SqlConnection mConn = new SqlConnection(Constlist.ConStr);
                mConn.Open();

                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = mConn;
                cmd.CommandType = CommandType.Text;

                cmd.CommandText = "select custom_order,track_serial_no,custommaterialNo,custom_serial_no,dpk_status,mac,mpn,mb_describe from DeliveredTable where order_receive_date between '" + startTime + "' and '" + endTime + "'";
                SqlDataReader querySdr = cmd.ExecuteReader();
                while (querySdr.Read())
                {
                    ReceiveOrderStruct temp = new ReceiveOrderStruct();
                    temp.orderNo          = querySdr[0].ToString();
                    temp.trackno          = querySdr[1].ToString();
                    temp.customMaterialNo = querySdr[2].ToString();
                    temp.custom_serial_no = querySdr[3].ToString();
                    temp.dpktype          = querySdr[4].ToString();
                    temp.mac        = querySdr[5].ToString();
                    temp.mpn        = querySdr[6].ToString();
                    temp.mbdescribe = querySdr[7].ToString();

                    receiveOrderList.Add(temp);
                }
                querySdr.Close();

                mConn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            generateExcelToCheck(receiveOrderList, startTime, endTime);
        }
        private void exportxmlbutton_Click(object sender, EventArgs e)
        {
            DateTime time1 = Convert.ToDateTime(this.dateTimePickerstart.Value.Date.ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo));
            DateTime time2 = Convert.ToDateTime(this.dateTimePickerend.Value.Date.ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo));

            if (DateTime.Compare(time1, time2) > 0) //判断日期大小
            {
                MessageBox.Show("开始日期大于结束");
                return;
            }

            string startTime = this.dateTimePickerstart.Value.ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            string endTime   = this.dateTimePickerend.Value.ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo);

            List <ReceiveOrderStruct> receiveOrderList = new List <ReceiveOrderStruct>();

            try
            {
                SqlConnection mConn = new SqlConnection(Constlist.ConStr);
                mConn.Open();

                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = mConn;
                cmd.CommandType = CommandType.Text;

                cmd.CommandText = "select vendor,product, source_brief,storehouse,custom_order,order_out_date,order_receive_date,custom_machine_type,mb_brief," +
                                  "custommaterialNo,dpk_status,track_serial_no,custom_serial_no,vendor_serail_no,uuid,mac,mpn,mb_describe,mb_make_date,warranty_period,custom_fault," +
                                  "guarantee,customResponsibility,lenovo_custom_service_no,lenovo_maintenance_no,lenovo_repair_no,whole_machine_no,inputuser from DeliveredTable where order_receive_date between '" + startTime + "' and '" + endTime + "'";
                SqlDataReader querySdr = cmd.ExecuteReader();
                while (querySdr.Read())
                {
                    ReceiveOrderStruct temp = new ReceiveOrderStruct();
                    temp.vendor              = querySdr[0].ToString();
                    temp.product             = querySdr[1].ToString();
                    temp.source_brief        = querySdr[2].ToString();
                    temp.storehouse          = querySdr[3].ToString();
                    temp.custom_order        = querySdr[4].ToString();
                    temp.order_out_date      = querySdr[5].ToString();
                    temp.order_receive_date  = querySdr[6].ToString();
                    temp.custom_machine_type = querySdr[7].ToString();
                    temp.mb_brief            = querySdr[8].ToString();
                    temp.custommaterialNo    = querySdr[9].ToString();
                    temp.dpk_status          = querySdr[10].ToString();
                    temp.track_serial_no     = querySdr[11].ToString();
                    temp.custom_serial_no    = querySdr[12].ToString();
                    temp.vendor_serail_no    = querySdr[13].ToString();
                    temp.uuid        = querySdr[14].ToString();
                    temp.mac         = querySdr[15].ToString();
                    temp.mpn         = querySdr[16].ToString();
                    temp.mb_describe = querySdr[17].ToString();

                    temp.mb_make_date         = querySdr[18].ToString();
                    temp.warranty_period      = querySdr[19].ToString();
                    temp.custom_fault         = querySdr[20].ToString();
                    temp.guarantee            = querySdr[21].ToString();
                    temp.customResponsibility = querySdr[22].ToString();

                    temp.lenovo_custom_service_no = querySdr[23].ToString();
                    temp.lenovo_maintenance_no    = querySdr[24].ToString();
                    temp.lenovo_repair_no         = querySdr[25].ToString();
                    temp.whole_machine_no         = querySdr[26].ToString();

                    temp.inputuser = querySdr[27].ToString();

                    receiveOrderList.Add(temp);
                }
                querySdr.Close();

                mConn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            generateExcelToCheck(receiveOrderList, startTime, endTime);
        }